Submission #269284

#TimeUsernameProblemLanguageResultExecution timeMemory
269284PeppaPigDancing Elephants (IOI11_elephants)C++14
26 / 100
9037 ms2560 KiB
#include "elephants.h" #include <bits/stdc++.h> #define pii pair<int, int> #define x first #define y second using namespace std; const int N = 1.5e5 + 5; int n, k, B, pos[N]; set<pii> S; void init(int _n, int _k, int X[]) { n = _n, k = _k; for(int i = 0; i < n; i++) S.emplace(X[i], i), pos[i] = X[i]; } int update(int i, int y) { S.erase(pii(pos[i], i)); S.emplace(pos[i] = y, i); auto it = S.begin(); int cnt = 1; while(1) { pii now = *it; auto nex = S.upper_bound(pii(now.x + k + 1, -1e9)); if(nex == S.end()) break; it = nex, ++cnt; } return cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...