# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
447760 | dxz05 | Dancing Elephants (IOI11_elephants) | C++14 | 1 ms | 304 KiB |
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>
using namespace std;
const int MAXN = 2e5 + 3e2;
int N, L;
int X[MAXN];
int perm[MAXN];
void init(int _N, int _L, int _X[]){
N = _N;
L = _L;
for (int i = 0; i < N; i++) {
X[i] = _X[i];
perm[i] = i;
}
sort(perm, perm + N, [](int i, int j){
return X[i] < X[j];
});
}
int update(int i, int y){
X[i] = y;
int j = i;
while (j < N - 1 && X[perm[j]] > X[perm[j + 1]]){
swap(perm[j], perm[j + 1]);
j++;
}
j = i;
while (j > 1 && X[perm[j]] < X[perm[j - 1]]){
swap(perm[j], perm[j - 1]);
j--;
}
for (j = 0; j < N; j++) cerr << X[perm[j]] << ' '; cerr << endl;
int ans = 1, last = X[perm[0]];
for (j = 0; j < N; j++){
int x = X[perm[j]];
if (x - last > L){
ans++;
last = x;
}
}
return ans;
}
Compilation message (stderr)
# | 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... |