Submission #1076935

#TimeUsernameProblemLanguageResultExecution timeMemory
1076935bleahbleahTortoise (CEOI21_tortoise)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define all(x) (x).begin(),(x).end() using namespace std; //#ifndef DLOCAL // #define cin fin // #define cout fout // ifstream cin(".in"); // ofstream cout(".out"); //#endif using ll = long long; using ld = long double; #define int ll #define sz(x) ((int)(x).size()) using pii = pair<int,int>; using tii = tuple<int,int,int>; const int nmax = 5e5 + 5; int Ld[nmax], Rd[nmax]; int v[nmax]; bool possible(multiset<int> s) { int last = -1, timer = 0; for(auto x : s) { if(last == -1) { timer += x - 1; } else { if(Ld[last] != Ld[x] || Rd[last] != Rd[x]) timer += x - last; else timer += min(last - Ld[last] + x - Ld[last], Rd[last] - last + Rd[last] - x); } if(timer > 2 * (x - 1)) { return 0; } last = x; //cerr << timer << '\n'; } //cerr << '\n'; //for(auto x: s) cerr << x << ' '; cerr << '\n'; //cerr << "ok\n"; return 1; } signed main() { cin.tie(0) -> sync_with_stdio(0); int n; cin >> n; ll cost = 0; for(int i = 1; i <= n; i++) cin >> v[i], cost += (v[i] != -1? v[i] : 0); for(int lst = -1e9 - 5, i = 1; i <= n; i++) { if(v[i] == -1) lst = i; else Ld[i] = lst; } for(int lst = 1e9 + 5, i = n; i > 0; i--) { if(v[i] == -1) lst = i; else Rd[i] = lst; } vector<pii> idxs; multiset<int> sofar; for(int i = 1; i <= n; i++) { if(v[i] == -1) continue; idxs.emplace_back(min(Rd[i] - i, i - Ld[i]), i); } sort(all(idxs)); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); shuffle(all(idxs)); for(auto [DD, x] : idxs) { while(v[x] > 0) { sofar.emplace(x); if(possible(sofar)) v[x]--; else { sofar.erase(sofar.find(x)); break; } } } cost = 0; for(int i = 1; i <= n; i++) cost += (v[i] != -1? v[i] : 0); cout << cost << '\n'; }

Compilation message (stderr)

tortoise.cpp: In function 'int main()':
tortoise.cpp:76:21: error: no matching function for call to 'shuffle(std::vector<std::pair<long long int, long long int> >::iterator, std::vector<std::pair<long long int, long long int> >::iterator)'
   76 |    shuffle(all(idxs));
      |                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from tortoise.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3748:5: note: candidate: 'template<class _RAIter, class _UGenerator> void std::shuffle(_RAIter, _RAIter, _UGenerator&&)'
 3748 |     shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3748:5: note:   template argument deduction/substitution failed:
tortoise.cpp:76:21: note:   candidate expects 3 arguments, 2 provided
   76 |    shuffle(all(idxs));
      |                     ^