#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 70000;
int X[MAXN], n, L;
vector<int> vec; // TODO: multiset
void init(int N, int L_, int X_[]) {
L = L_;
for (int i = 0; i < N; i++) {
X[i] = X_[i];
vec.push_back(X[i]);
}
while (vec.size() < MAXN)
vec.push_back(-1);
n = N;
}
int update(int i, int y) {
vec.erase(lower_bound(vec.begin(), vec.begin() + n, X[i]));
X[i] = y;
vec.insert(lower_bound(vec.begin(), vec.begin() + n - 1, X[i]), X[i]);
int ans = 0;
int v = -(L + 1);
for (int i = 0; i < MAXN; i++) {
if (vec[i] > v + L) {
v = vec[i];
ans++;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
976 KB |
Output is correct |
2 |
Correct |
2 ms |
976 KB |
Output is correct |
3 |
Correct |
3 ms |
976 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
976 KB |
Output is correct |
2 |
Correct |
2 ms |
976 KB |
Output is correct |
3 |
Correct |
3 ms |
976 KB |
Output is correct |
4 |
Correct |
4 ms |
976 KB |
Output is correct |
5 |
Correct |
5 ms |
976 KB |
Output is correct |
6 |
Correct |
4 ms |
976 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
976 KB |
Output is correct |
2 |
Correct |
2 ms |
976 KB |
Output is correct |
3 |
Correct |
3 ms |
976 KB |
Output is correct |
4 |
Correct |
4 ms |
976 KB |
Output is correct |
5 |
Correct |
5 ms |
976 KB |
Output is correct |
6 |
Correct |
4 ms |
976 KB |
Output is correct |
7 |
Correct |
3561 ms |
1684 KB |
Output is correct |
8 |
Correct |
3552 ms |
1616 KB |
Output is correct |
9 |
Correct |
1791 ms |
1944 KB |
Output is correct |
10 |
Correct |
1895 ms |
1980 KB |
Output is correct |
11 |
Correct |
1761 ms |
1872 KB |
Output is correct |
12 |
Correct |
6056 ms |
1928 KB |
Output is correct |
13 |
Correct |
1939 ms |
1872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
976 KB |
Output is correct |
2 |
Correct |
2 ms |
976 KB |
Output is correct |
3 |
Correct |
3 ms |
976 KB |
Output is correct |
4 |
Correct |
4 ms |
976 KB |
Output is correct |
5 |
Correct |
5 ms |
976 KB |
Output is correct |
6 |
Correct |
4 ms |
976 KB |
Output is correct |
7 |
Correct |
3561 ms |
1684 KB |
Output is correct |
8 |
Correct |
3552 ms |
1616 KB |
Output is correct |
9 |
Correct |
1791 ms |
1944 KB |
Output is correct |
10 |
Correct |
1895 ms |
1980 KB |
Output is correct |
11 |
Correct |
1761 ms |
1872 KB |
Output is correct |
12 |
Correct |
6056 ms |
1928 KB |
Output is correct |
13 |
Correct |
1939 ms |
1872 KB |
Output is correct |
14 |
Correct |
3126 ms |
1952 KB |
Output is correct |
15 |
Correct |
5166 ms |
1972 KB |
Output is correct |
16 |
Execution timed out |
9019 ms |
2548 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
976 KB |
Output is correct |
2 |
Correct |
2 ms |
976 KB |
Output is correct |
3 |
Correct |
3 ms |
976 KB |
Output is correct |
4 |
Correct |
4 ms |
976 KB |
Output is correct |
5 |
Correct |
5 ms |
976 KB |
Output is correct |
6 |
Correct |
4 ms |
976 KB |
Output is correct |
7 |
Correct |
3561 ms |
1684 KB |
Output is correct |
8 |
Correct |
3552 ms |
1616 KB |
Output is correct |
9 |
Correct |
1791 ms |
1944 KB |
Output is correct |
10 |
Correct |
1895 ms |
1980 KB |
Output is correct |
11 |
Correct |
1761 ms |
1872 KB |
Output is correct |
12 |
Correct |
6056 ms |
1928 KB |
Output is correct |
13 |
Correct |
1939 ms |
1872 KB |
Output is correct |
14 |
Correct |
3126 ms |
1952 KB |
Output is correct |
15 |
Correct |
5166 ms |
1972 KB |
Output is correct |
16 |
Execution timed out |
9019 ms |
2548 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |