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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
#define pb push_back
#define f first
#define s second
const int MAXN = 1.5e5 + 100;
int pos[MAXN];
multiset<int> pts;
int L;
void init(int N, int iL, int X[]) {
L = iL;
for (int i = 0; i < N; i++) {
pos[i] = X[i];
pts.insert(X[i]);
}
}
int lCnt = 0;
int update(int i, int y) {
pts.erase(pos[i]);
pos[i] = y;
pts.insert(y);
int cnt = 0;
if (lCnt >= 1) {
int nxt = *pts.begin() + L;
int cnt = 1;
for (int x : pts) {
if (x > nxt) {
nxt = x + L;
cnt++;
}
}
lCnt = cnt;
return cnt;
} else {
auto it = pts.begin();
while (it != pts.end()) {
it = pts.upper_bound((*it) + L);
cnt++;
}
lCnt = 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... |