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>
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
int n, l;
int a[150'005][2];
void init(int N, int L, int X[]) {
n = N, l = L;
pair<int, int> v[n];
for (int i = 0; i < n; i++) {
v[i] = {X[i], i};
}
sort(v, v + n);
for (int i = 0; i < n; i++) {
a[i][0] = v[i].first;
a[i][1] = v[i].second;
}
}
int update(int x, int y) {
int pos = -1;
for (int i = 0; i < n; i++) {
if (a[i][1] == x) {
pos = i;
break;
}
}
if (a[pos][0] < y) {
a[pos][0] = y;
for (int i = pos; i + 1 < n && a[i][0] > a[i + 1][0]; i++) {
swap(a[i][0], a[i + 1][0]);
swap(a[i][1], a[i + 1][1]);
}
} else {
a[pos][0] = y;
for (int i = pos; i - 1 >= 0 && a[i][0] < a[i - 1][0]; i--) {
swap(a[i][0], a[i - 1][0]);
swap(a[i][1], a[i - 1][1]);
}
}
int prv = a[0][0] + l, cnt = 0;
for (int i = 1; i < n; i++) {
cnt += (a[i][0] > prv);
if (a[i][0] > prv) prv = a[i][0] + l;
}
return cnt + 1;
}
# | 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... |