Submission #375375

#TimeUsernameProblemLanguageResultExecution timeMemory
375375Alex_tz307Art Exhibition (JOI18_art)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using int64 = long long; const int NMAX = 5e5 + 5; int N, lg2[NMAX]; int64 pref_sum[NMAX], rmq_max[NMAX][20], ans; pair<int64,int> a[NMAX]; void compute_lg2() { lg2[1] = 0; for(int i = 2; i <= N; ++i) lg2[i] = lg2[i >> 1] + 1; } void compute_rmq() { for(int i = 1; i <= N; ++i) rmq_max[i][0] = pref_sum[i] - a[i].first; for(int j = 1; (1 << j) <= N; ++j) for(int i = 1; i + (1 << j) - 1 <= N; ++i) rmq_max[i][j] = max(rmq_max[i][j - 1], rmq_max[i + (1 << (j - 1))][j - 1]); } int query_max(int l, int r) { int k = lg2[r - l + 1]; int dif = (r - l + 1) - (1 << k); return max(rmq_max[l][k], rmq_max[l + dif][k]); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> N; for(int i = 1; i <= N; ++i) cin >> a[i].first >> a[i].second; sort(a + 1, a + N + 1); for(int i = 1; i <= N; ++i) pref_sum[i] = pref_sum[i - 1] + a[i].second; compute_lg2(); compute_rmq(); for(int i = 1; i <= N; ++i) { int best = a[i].first + query_max(i, N) - pref_sum[i - 1]; ans = max(ans, best); } cout << ans << '\n'; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:45:28: error: no matching function for call to 'max(int64&, int&)'
   45 |         ans = max(ans, best);
      |                            ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from art.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
art.cpp:45:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |         ans = max(ans, best);
      |                            ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from art.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
art.cpp:45:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |         ans = max(ans, best);
      |                            ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from art.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
art.cpp:45:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |         ans = max(ans, best);
      |                            ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from art.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
art.cpp:45:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |         ans = max(ans, best);
      |                            ^