제출 #1187097

#제출 시각아이디문제언어결과실행 시간메모리
1187097aladdin1Pilot (NOI19_pilot)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define int long long #define ll long long //using ll=long long; #define ld long double #define inf 1000000000 #define all(v) v.begin(),v.end() using namespace std; const int N=1e6+5; const int MAX = 1e7+9; const int MOD = 1e9 + 7; const int mod=9929; /* ----------------------------------------------------------------------------------- BBBBBBBBBB LLL BBBBBBBBBB DDDDDDDD DDDDDDD III N N | BB BB LLL BB BB DD DD DD DD III NN N | BB BB LLL BB BB DD DD DD DD III N N N | BBBBBBBBBB LLL BBBBBBBBBB DD DD DD DD III N N N | BB BB LLL BB BB DD DD DD DD III N N N | BB BB LLL BB BB DD DD DD DD III N N N | BB BB LLL BB BB DD DD DD DD III N NN | BB BB LLLLLLLLL BB BB DDDDDDDD DDDDDDD III N N | | ----------------------------------------------------------------------------------- */ void solve(){ int n,q;cin>>n>>q; vector<int>v(n); for(int i=0;i<n;i++)cin>>v[i]; bool b=is_sorted(all(v)); while(q--){ int mx=0,k=0,cnt=0; int x;cin>>x; if(b){ int f=upper_bound(all(v)); cout<<f*(f+1)/2<<"\n"; } else{ for(int i=0;i<n;i++){ mx=max(mx,v[i]); if(mx<=x)k++; else{ mx=0; cnt+=k*(k+1)/2; k=0; } } cnt+=k*(k+1)/2; cout<<cnt<<"\n"; } } } signed main(){ int t=1;//cin>>t; while(t--){ solve(); } }

컴파일 시 표준 에러 (stderr) 메시지

pilot.cpp: In function 'void solve()':
pilot.cpp:35:26: error: no matching function for call to 'upper_bound(std::vector<long long int>::iterator, std::vector<long long int>::iterator)'
   35 |         int f=upper_bound(all(v));
      |               ~~~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from pilot.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:2067:5: note: candidate: 'template<class _FIter, class _Tp> constexpr _FIter std::upper_bound(_FIter, _FIter, const _Tp&)'
 2067 |     upper_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/11/bits/stl_algo.h:2067:5: note:   template argument deduction/substitution failed:
pilot.cpp:35:26: note:   candidate expects 3 arguments, 2 provided
   35 |         int f=upper_bound(all(v));
      |               ~~~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from pilot.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:2098:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> constexpr _FIter std::upper_bound(_FIter, _FIter, const _Tp&, _Compare)'
 2098 |     upper_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/11/bits/stl_algo.h:2098:5: note:   template argument deduction/substitution failed:
pilot.cpp:35:26: note:   candidate expects 4 arguments, 2 provided
   35 |         int f=upper_bound(all(v));
      |               ~~~~~~~~~~~^~~~~~~~