#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 3e2;
int N, L;
int X[MAXN], A[MAXN];
void init(int _N, int _L, int _X[]){
N = _N;
L = _L;
for (int i = 0; i < N; i++) X[i] = _X[i];
for (int i = 0; i < N; i++) A[i] = X[i];
sort(A, A + N);
}
int update(int pos, int val){
int ind = 0;
for (int i = 0; i < N; i++){
if (A[i] == X[pos]) A[i] = val, ind = i;
}
if (X[pos] < val){
X[pos] = val;
int j = ind;
while (j < N - 1 && A[j] > A[j + 1]) {
swap(A[j], A[j + 1]);
j++;
}
} else {
X[pos] = val;
int j = ind;
while (j > 1 && A[j] < A[j - 1]) {
swap(A[j], A[j - 1]);
j--;
}
}
//for (int i = 0; i < N; i++) cerr << A[i] << ' '; cerr << endl;
int ans = 1, last = A[0];
for (int i = 0; i < N; i++){
int x = A[i];
if (x - last > L){
ans++;
last = x;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |