Language: C++

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

int max_a[111111];
int min_a[111111];
//bool use[111111];
map<int,int> mp;
int main(void){
  int n,t;
  cin>>n>>t;
  int x;
  vector<int> a;
  for(int i=0;i<n;i++){
    cin>>x;
    a.pb(x);
  }
  min_a[0]=a[0];
  max_a[n-1]=a[n-1];
  for(int i=1;i<n;i++){
    min_a[i]=min(min_a[i-1],a[i]);
    max_a[n-i-1]=max(max_a[n-i],a[n-i-1]);
  }
  int r=0;
  for(int i=0;i<n;i++){
    r=max(r,max_a[i]-min_a[i]);
  }
  int res=0;
  for(int i=0;i<n;i++){
    if(max_a[i]-min_a[i]==r){
      if(mp[max_a[i]]!=1) res++;
      map[max_a[i]]=1;
    }
  }
  cout<<res<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:16: error: expected ']' before '[' token
   45 |       map[max_a[i]]=1;
      |                ^
      |                ]
a.cc:45:21: error: class template argument deduction failed:
   45 |       map[max_a[i]]=1;
      |                     ^
a.cc:45:21: error: no matching function for call to 'map(int)'
In file included from /usr/include/c++/14/map:63,
                 from a.cc:7:
/usr/include/c++/14/bits/stl_map.h:1473:5: note: candidate: 'template<class _InputIterator, class _Compare, class _Allocator, class, class, class> std::map(_InputIterator, _InputIterator, _Compare, _Allocator)-> map<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type, typename iterator_traits< <template-parameter-1-1> >::value_type::second_type, _Compare, _Allocator>'
 1473 |     map(_InputIterator, _InputIterator,
      |     ^~~
/usr/include/c++/14/bits/stl_map.h:1473:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:1482:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Allocator, class, class> std::map(initializer_list<pair<_T1, _T2> >, _Compare, _Allocator)-> map<_Key, _Tp, _Compare, _Allocator>'
 1482 |     map(initializer_list<pair<_Key, _Tp>>,
      |     ^~~
/usr/include/c++/14/bits/stl_map.h:1482:5: note:   template argument deduction/substitution failed:
a.cc:45:21: note:   mismatched types 'std::initializer_list<std::pair<_T1, _T2> >' and 'int'
   45 |       map[max_a[i]]=1;
      |                     ^
/usr/include/c++/14/bits/stl_map.h:1489:5: note: candidate: 'template<class _InputIterator, class _Allocator, class, class> std::map(_InputIterator, _InputIterator, _Allocator)-> map<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type, typename iterator_traits< <template-parameter-1-1> >::value_type::second_type, less<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type>, _Allocator>'
 1489 |     map(_InputIterator, _InputIterator, _Allocator)
      |     ^~~
/usr/include/c++/14/bits/stl_map.h:1489:5: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:1495:5: note: candidate: 'template<class _Key, class _Tp, class _Allocator, class> std::map(initializer_list<pair<_T1, _T2> >, _Allocator)-> map<_Key, _Tp, less<_Key>, _Allocator>'
 1495 |     map(initializer_list<pair<_Key, _Tp>>, _Allocator)
      |     ^~~
/usr/include/c++/14/bits/stl_map.h:1495:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:102:11: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Alloc>)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  102 |     class map
      |           ^~~
/usr/include/c++/14/bits/stl_map.h:102:11: note:   template argument deduction/substitution failed:
a.cc:45:21: note:   mismatched types 'std::map<_Key, _Tp, _Compare, _Alloc>' and 'int'
   45 |       map[max_a[i]]=1;
      |                     ^
/usr/include/c++/14/bits/stl_map.h:197:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map()-> std::map<_Key, _Tp, _Compare, _Alloc>'
  197 |       map() = default;
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:197:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:219:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(const std::map<_Key, _Tp, _Compare, _Allocator>&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  219 |       map(const map&) = default;
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:219:7: note:   template argument deduction/substitution failed:
a.cc:45:21: note:   mismatched types 'const std::map<_Key, _Tp, _Compare, _Allocator>' and 'int'
   45 |       map[max_a[i]]=1;
      |                     ^
/usr/include/c++/14/bits/stl_map.h:227:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Allocator>&&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  227 |       map(map&&) = default;
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:227:7: note:   template argument deduction/substitution failed:
a.cc:45:21: note:   mismatched types 'std::map<_Key, _Tp, _Compare, _Allocator>' and 'int'
   45 |       map[max_a[i]]=1;
      |                     ^
/usr/include/c++/14/bits/stl_map.h:240:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::initializer_list<std::pair<const _Key, _Tp> >, const _Compare&, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  240 |       map(initializer_list<value_type> __l,
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:240:7: note:   template argument deduction/substitution failed:
a.cc:45:21: note:   mismatched types 'std::initializer_list<std::pair<const _Key, _Tp> >' and 'int'
   45 |       map[max_a[i]]=1;
      |                     ^
/usr/include/c++/14/bits/stl_map.h:252:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(const std::map<_Key, _Tp, _Compare, _Allocator>&, std::__type_identity_t<_Alloc>&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  252 |       map(const map& __m, const __type_identity_t<allocator_type>& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:252:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:256:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Allocator>&&, std::__type_identity_t<_Alloc>&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  256 |       map(map&& __m, const __type_identity_t<allocator_type>& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:256:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:262:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::initializer_list<std::pair<const _Key, _Tp> >, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  262 |       map(initializer_list<value_type> __l, const allocator_type& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:262:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:268:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  268 |         map(_InputIterator __first, _InputIterator __last,
      |         ^~~
/usr/include/c++/14/bits/stl_map.h:268:9: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:285:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  285 |         map(_InputIterator __first, _InputIterator __last)
      |         ^~~
/usr/include/c++/14/bits/stl_map.h:285:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:302:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator, const _Compare&, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  302 |         map(_InputIterator __first, _InputIterator __last,
      |         ^~~
/usr/include/c++/14/bits/stl_map.h:302:9: note:   candidate expects 3 arguments, 1 provided
a.cc:45:21: note: explicit deduction guides not considered for copy-initialization
   45 |       map[max_a[i]]=1;
      |                     ^