Language: C++

#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
#define fin {cout<<-1<<endl;return 0;}
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  reverse(v.begin(),v.end());
  typedef pair<int,int> P;
  map<int,P> s;
  s.insert(P(LINF,0));
  for(int i=0;i<N;i++){
    P p=*s.upper_bound(P(v[i],0));
    if(p.first<LINF)s.erase(p);
    s.insert(v[i],i);
  }
  cout<<s.size()-1<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:11: error: no matching function for call to 'std::map<long long int, std::pair<long long int, long long int> >::insert(P)'
   18 |   s.insert(P(LINF,0));
      |   ~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:847:9: note: candidate: 'template<class _Pair> std::__enable_if_t<((bool)std::is_constructible<std::pair<const _Key, _Val>, _Pair>::value), std::pair<typename std::_Rb_tree<_Key, std::pair<const _Key, _Val>, std::_Select1st<std::pair<const _Key, _Val> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Val> >::other>::iterator, bool> > std::map<_Key, _Tp, _Compare, _Alloc>::insert(_Pair&&) [with _Key = long long int; _Tp = std::pair<long long int, long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > >]'
  847 |         insert(_Pair&& __x)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_map.h:847:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::__enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::pair<std::_Rb_tree_iterator<std::pair<const long long int, std::pair<long long int, long long int> > >, bool>]':
/usr/include/c++/14/bits/stl_map.h:847:2:   required by substitution of 'template<class _Pair> std::__enable_if_t<((bool)std::is_constructible<std::pair<const long long int, std::pair<long long int, long long int> >, _Pair>::value), std::pair<std::_Rb_tree_iterator<std::pair<const long long int, std::pair<long long int, long long int> > >, bool> > std::map<long long int, std::pair<long long int, long long int> >::insert(_Pair&&) [with _Pair = std::pair<long long int, long long int>]'
a.cc:18:11:   required from here
   18 |   s.insert(P(LINF,0));
      |   ~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/type_traits:138:11: error: no type named 'type' in 'struct std::enable_if<false, std::pair<std::_Rb_tree_iterator<std::pair<const long long int, std::pair<long long int, long long int> > >, bool> >'
  138 |     using __enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:924:9: note: candidate: 'template<class _Pair> std::__enable_if_t<((bool)std::is_constructible<std::pair<const _Key, _Val>, _Pair>::value), typename std::_Rb_tree<_Key, std::pair<const _Key, _Val>, std::_Select1st<std::pair<const _Key, _Val> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Val> >::other>::iterator> std::map<_Key, _Tp, _Compare, _Alloc>::insert(const_iterator, _Pair&&) [with _Key = long long int; _Tp = std::pair<long long int, long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > >]'
  924 |         insert(const_iterator __position, _Pair&& __x)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_map.h:924:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:942:9: note: candidate: 'template<class _InputIterator> void std::map<_Key, _Tp, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _Key = long long int; _Tp = std::pair<long long int, long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > >]'
  942 |         insert(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_map.h:942:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:661:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::insert_return_type std::map<_Key, _Tp, _Compare, _Alloc>::insert(node_type&&) [with _Key = long long int; _Tp = std::pair<long long int, long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > >; insert_return_type = std::_Rb_tree<long long int, std::pair<const long long int, std::pair<long long int, long long int> >, std::_Select1st<std::pair<const long long int, std::pair<long long int, long long int> > >, std::less<long long int>, std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > > >::insert_return_type; node_type = std::_Rb_tree<long long int, std::pair<const long long int, std::pair<long long int, long long int> >, std::_Select1st<std::pair<const long long int, std::pair<long long int, long long int> > >, std::less<long long int>, std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > > >::node_type]'
  661 |       insert(node_type&& __nh)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_map.h:661:26: note:   no known conversion for argument 1 from 'P' {aka 'std::pair<long long int, long long int>'} to 'std::map<long long int, std::pair<long long int, long long int> >::node_type&&' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, std::pair<long long int, long long int> >, std::_Select1st<std::pair<const long long int, std::pair<long long int, long long int> > >, std::less<long long int>, std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > > >::node_type&&'}
  661 |       insert(node_type&& __nh)
      |              ~~~~~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_map.h:666:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::insert(const_iterator, node_type&&) [with _Key = long long int; _Tp = std::pair<long long int, long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > >; iterator = std::_Rb_tree<long long int, std::pair<const long long int, std::pair<long long int, long long int> >, std::_Select1st<std::pair<const long long int, std::pair<long long int, long long int> > >, std::less<long long int>, std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > > >::iterator; const_iterator = std::_Rb_tree<long long int, std::pair<const long long int, std::pair<long long int, long long int> >, std::_Select1st<std::pair<const long long int, std::pair<long long int, long long int> > >, std::less<long long int>, std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > > >::const_iterator; node_type = std::_Rb_tree<long long int, std::pair<const long long int, std::pair<long long int, long long int> >, std::_Select1st<std::pair<const long long int, std::pair<long long int, long long int> > >, std::less<long long int>, std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > > >::node_type]'
  666 |       insert(const_iterator __hint, node_type&& __nh)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_map.h:666:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:834:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, std::pair<const _Key, _Val>, std::_Select1st<std::pair<const _Key, _Val> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Val> >::other>::iterator, bool> std::map<_Key, _Tp, _Compare, _Alloc>::insert(const value_type&) [with _Key = long long int; _Tp = std::pair<long long int, long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > >; typename std::_Rb_tree<_Key, std::pair<const _Key, _Val>, std::_Select1st<std::pair<const _Key, _Val> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Val> >::other>::iterator = std::_Rb_tree<long long int, std::pair<const long long int, std::pair<long long int, long long int> >, std::_Select1st<std::pair<const long long int, std::pair<long long int, long long int> > >, std::less<long long int>, std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > > >::iterator; typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Val> >::other = std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > >; typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Val> > = __gnu_cxx::__alloc_traits<std::allocator<std::pair<const long long int, std::pair<long long int, long long int> > >, std::pair<const long long int, std::pair<long long int, long long int> > >::rebind<std::pair<const long long int, std::pair<long long int, long long int> > >; typename _Allocator::value_type = std::pair<const long long int, std::pair<long long int, long long int> >; value_type = std::pair<const long long int, std::pair<long long int, long long int> >]'
  834 |       insert(const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_map.h:834:32: note:   no known conversion for argument 1 from 'P' {aka 'std::pair<long long int, long long int>'} to 'const std::map<long long int, std::pair<long long int, long long int> >::value_type&' {aka 'const std::pair<const long long int, std::pair<long long int, long long int> >&'}
  834 |       insert(const value_type& __x)
      |              ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:841:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, std::pair<const _Key, _Val>, std::_Select1st<std::pair<const _Key, _Val> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Val> >::other>::iterator, bool> std::map<_Key, _Tp, _Compare, _Alloc>::insert(value_type&&) [with _Key = long long int; _Tp = std::pair<long long int, long long int>; _