#pragma GCC optimize("Ofast")
#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){
for (int i = 0; i < N; i++){
if (A[i] == X[pos]) A[i] = val;
}
X[pos] = val;
for (int i = 0; i < N - 1; i++){
if (A[i] > A[i + 1]) swap(A[i], A[i + 1]);
}
for (int i = N - 1; i > 1; i--){
if (A[i - 1] > A[i]) swap(A[i - 1], A[i]);
}
//for (int i = 0; i < N; i++) cerr << X[i] << ' '; cerr << endl;
//for (int i = 0; i < N; i++) cerr << A[i] << ' '; cerr << endl << endl;
int ans = 1, last = A[0];
for (int i = 0; i < N; i++){
if (A[i] - last > L){
ans++;
last = A[i];
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
3437 ms |
1052 KB |
Output is correct |
8 |
Correct |
4987 ms |
1108 KB |
Output is correct |
9 |
Correct |
7789 ms |
1488 KB |
Output is correct |
10 |
Execution timed out |
9096 ms |
2756 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
3437 ms |
1052 KB |
Output is correct |
8 |
Correct |
4987 ms |
1108 KB |
Output is correct |
9 |
Correct |
7789 ms |
1488 KB |
Output is correct |
10 |
Execution timed out |
9096 ms |
2756 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
3437 ms |
1052 KB |
Output is correct |
8 |
Correct |
4987 ms |
1108 KB |
Output is correct |
9 |
Correct |
7789 ms |
1488 KB |
Output is correct |
10 |
Execution timed out |
9096 ms |
2756 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |