This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |