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>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
const int N = 1e5 + 10;
int n, l;
int a[N], b[N];
void init(int N, int L, int X[])
{
n = N;
l = L;
for(int i = 0; i < n; i++) a[i] = X[i];
}
int update(int i, int y)
{
a[i] = y;
for(int i = 0; i < n; i++) b[i] = a[i];
sort(b, b + n);
int pre = -1e9, ans = 0;
for(int i = 0; i < n; i++) if (b[i] - pre > l) {
pre = b[i];
ans++;
}
return ans;
}
#ifdef ngu
int x[N];
int main() {
freopen ("task.inp", "r", stdin);
freopen ("task.out", "w", stdout);
int n, l, m; cin >> n >> l >> m;
for(int i = 0; i < n; i++) cin >> x[i];
init(n, l, x);
while (m--) {
int i, v; cin >> i >> v;
cout << update(i, v) << endl;
}
}
#endif // ngu
# | 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... |