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>
#include "elephants.h"
using namespace std;
const int N = 150000 + 7;
int n, x[N], len, normal_ord[N];
int ind;
void init(int nn, int lenlen, int initial[]) {
ind = 0;
n = nn;
len = lenlen;
for (int i = 0; i < n; i++) {
x[i] = normal_ord[i] = initial[i];
}
return;
}
void print(int v[]) {
cout << " ----> ";
for (int i = 0; i < n; i++) {
cout << v[i] << " ";
}
cout << "\n";
}
int update(int ii, int yy) {
{
int value = normal_ord[ii];
normal_ord[ii] = yy;
int l = 0, r = n - 1, sol = -1;
while (l <= r) {
int m = (l + r) / 2;
if (x[m] == value) {
sol = m;
break;
}
if (x[m] < value) {
l = m + 1;
} else {
r = m - 1;
}
}
assert(sol != -1);
ii = sol;
}
x[ii] = yy;
sort(x, x + n);
ind++;
int cost = 0, l = 0;
while (l < n) {
cost++;
int r = l;
while (r + 1 < n && x[r + 1] - x[l] <= len) {
r++;
}
l = r + 1;
}
return cost;
}
# | 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... |