Submission #1083555

#TimeUsernameProblemLanguageResultExecution timeMemory
1083555knot222Commuter Pass (JOI18_commuter_pass)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <iostream> using namespace std; #define ll long long int const ll inf = 1e10; int main() { ll N,X; cin>>N>>X; vector<ll> a(N+10); vector<ll> b(N+10); for (int i=1;i<=N;i++) { cin>>a[i]; b[N+1-i] = -a[i]; } vector<ll> l1(N+10, inf); vector<ll> ll1(N+10,inf); l1[0] = -inf; for (int i=1;i<=N;i++) { int l = upper_bound(l1.begin()+1, l1.end(), a[i]) - (l1.begin()); if (l1[l-1] < a[i] && a[i] < l1[l]) { l1[l] = a[i]; } ll1[i] = l; } vector<ll> l2(N+10, inf); vector<ll> ll2(N+10,inf); l2[0] = -inf; for (int i=1;i<=N;i++) { int l = upper_bound(l2.begin()+1, l2.end(), b[i]) - (l2.begin()); if (l2[l-1] < b[i] && b[i] < l2[l]) { l2[l] = b[i]; } ll2[N+1-i] = l; if (N+1-i<N) { ll2[N+1-i] = max(ll2[N+1-i+1], l); } } ll ans = 0; for (int i=1;i<N;i++) { if (a[i]-X+1<=a[i+1]) { //cout << ans; ans = max(ans, ll1[i]+ll2[i+1]); } } cout << ans; return 0; } /* 8 10 7 3 5 12 2 7 3 4 */

Compilation message (stderr)

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:36:45: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, int&)'
   36 |             ll2[N+1-i] = max(ll2[N+1-i+1], l);
      |                                             ^
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 commuter_pass.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:
commuter_pass.cpp:36:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |             ll2[N+1-i] = max(ll2[N+1-i+1], l);
      |                                             ^
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 commuter_pass.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:
commuter_pass.cpp:36:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |             ll2[N+1-i] = max(ll2[N+1-i+1], l);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from commuter_pass.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:
commuter_pass.cpp:36:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |             ll2[N+1-i] = max(ll2[N+1-i+1], l);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from commuter_pass.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:
commuter_pass.cpp:36:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |             ll2[N+1-i] = max(ll2[N+1-i+1], l);
      |                                             ^