제출 #984558

#제출 시각아이디문제언어결과실행 시간메모리
984558AcanikolicGlobal Warming (CEOI18_glo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define F first #define S second const int N = 500 + 10; const int inf = 2e9; const int mod = 998244353; using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n,x,res = 0; cin >> n >> x; vector<int>a(n); for(int i = 0; i < n; i++) { cin >> a[i]; a[i] -= x; } vector<pair<int,int>>pref(n); vector<int>v; for(int i = 0; i < n; i++) { if(v.empty() || v.back() < a[i]) { v.pb(a[i]); }else { int lb = lower_bound(v.begin(),v.end(),a[i]) - v.begin(); v[lb] = a[i]; } pref[i] = {v.back(),v.size()}; } res = pref[n - 1].S; for(int i = 0; i < n; i++) a[i] += x; vector<int>vec; for(int i = n - 1; i > 0; i--) { if(vec.empty() || vec.back() > a[i]) { vec.pb(a[i]); }else { if(vec[0] < a[i]) { vec[0] = a[i]; continue; } int lb = lower_bound(v.begin(),v.end(),v[i]) - v.begin(); lb -= 1; vec[lb] = a[i]; } int l = 0,r = i - 1,ans = -1; while(l <= r) { int mid = (l + r) / 2; if(pref[mid].F < vec.back()) { ans = mid; l = mid + 1; }else { r = mid - 1; } } res = max(res,vec.size() + (ans != -1 ? pref[ans].S : 0)); } cout << res; return 0; }

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

glo.cpp: In function 'int main()':
glo.cpp:66:59: error: no matching function for call to 'max(long long int&, long long unsigned int)'
   66 |   res = max(res,vec.size() + (ans != -1 ? pref[ans].S : 0));
      |                                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from glo.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
glo.cpp:66:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   66 |   res = max(res,vec.size() + (ans != -1 ? pref[ans].S : 0));
      |                                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from glo.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
glo.cpp:66:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   66 |   res = max(res,vec.size() + (ans != -1 ? pref[ans].S : 0));
      |                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from glo.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
glo.cpp:66:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   66 |   res = max(res,vec.size() + (ans != -1 ? pref[ans].S : 0));
      |                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from glo.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
glo.cpp:66:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   66 |   res = max(res,vec.size() + (ans != -1 ? pref[ans].S : 0));
      |                                                           ^