Submission #1032047

#TimeUsernameProblemLanguageResultExecution timeMemory
1032047TurkhuuClosing Time (IOI23_closing)C++17
Compilation error
0 ms0 KiB
#include "closing.h" #include <bits/stdc++.h> using namespace std; using ll = long long; int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) { vector<ll> pfs(N); for (int i = 0; i < N - 1; i++) { pfs[i + 1] = pfs[i] + W[i]; } auto dis = [&](int x, int y) { if (x > y) swap(x, y); return pfs[y] - pfs[x]; }; vector<ll> one(N), two(N), sx(N + 1), sy(N + 1), s2(N + 1), s1(N + 1); for (int i = 0; i < N; i++) { tie(one[i], two[i]) = minmax(dis(X, i), dis(Y, i)); sx[i + 1] = sx[i] + dis(X, i); sy[i + 1] = sy[i] + dis(Y, i); s1[i + 1] = s1[i] + one[i]; s2[i + 1] = s2[i] + two[i]; } int ans = 0; vector<tuple<ll, int, int>> a; for (int lx = 0; lx <= X; lx++) { for (int rx = X; rx < N; rx++) { a.emplace_back(sx[rx + 1] - sx[lx], lx, rx); } } sort(a.begin(), a.end()); int M = a.size(); vector<int> b(M); for (int i = 0; i < M; i++) { auto [_, l, r] = a[i]; b[i] = max(i == 0 ? 0 : b[i - 1], r - l + 1); } for (int ly = 0; ly <= Y; ly++) { for (int ry = Y; ry < N; ry++) { ll s = sy[ry + 1] - sy[ly]; if (s > K) continue; ans = max(ans, ry - ly + 1 + b[upper_bound(a.begin(), a.end(), {K - s, N, N}) - a.begin() - 1]); } } for (int l2 = 0; l2 < N; l2++) { for (int r2 = l2; r2 < N; r2++) { for (int l1 = 0; l1 <= min(X, l2); l1++) { for (int r1 = max(Y, r2); r1 < N; r1++) { if (s2[r2 + 1] - s2[l2] + s1[l2] - s1[l1] + s1[r1 + 1] - s1[r2 + 1] <= K) { ans = max(ans, r1 - l1 + 1 + r2 - l2 + 1); } } } } } return ans; }

Compilation message (stderr)

closing.cpp: In function 'int max_score(int, int, int, ll, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:40:89: error: no matching function for call to 'upper_bound(std::vector<std::tuple<long long int, int, int> >::iterator, std::vector<std::tuple<long long int, int, int> >::iterator, <brace-enclosed initializer list>)'
   40 |             ans = max(ans, ry - ly + 1 + b[upper_bound(a.begin(), a.end(), {K - s, N, N}) - a.begin() - 1]);
      |                                                                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from closing.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:2087:5: note: candidate: 'template<class _FIter, class _Tp> _FIter std::upper_bound(_FIter, _FIter, const _Tp&)'
 2087 |     upper_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:2087:5: note:   template argument deduction/substitution failed:
closing.cpp:40:89: note:   couldn't deduce template parameter '_Tp'
   40 |             ans = max(ans, ry - ly + 1 + b[upper_bound(a.begin(), a.end(), {K - s, N, N}) - a.begin() - 1]);
      |                                                                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from closing.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:2118:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::upper_bound(_FIter, _FIter, const _Tp&, _Compare)'
 2118 |     upper_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:2118:5: note:   template argument deduction/substitution failed:
closing.cpp:40:89: note:   candidate expects 4 arguments, 3 provided
   40 |             ans = max(ans, ry - ly + 1 + b[upper_bound(a.begin(), a.end(), {K - s, N, N}) - a.begin() - 1]);
      |                                                                                         ^