#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
set<pair<int,int>> pos;
int L;
void init(int N, int L_, int X[]) {
L = L_;
n = N;
a.resize(n);
for(int i = 0; i < n; i++) {
a[i] = X[i];
pos.insert({a[i], i});
}
}
int update(int i, int y) {
pos.erase(make_pair(a[i], i));
a[i] = y;
pos.insert(make_pair(a[i], i));
int mx = pos.rbegin()->first;
int l = pos.begin()->first + L+1;
int ans = 1;
// cerr << l << " " << mx << endl;
while(l <= mx) {
l = pos.lower_bound(make_pair(l,0))->first + L + 1;
// cerr << l << endl;
ans++;
}
// cerr << L << endl;
// for(auto x: pos) {
// cerr << x.first << " " << x.second << endl;
// }
// cerr << endl;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Execution timed out |
9033 ms |
2552 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Execution timed out |
9033 ms |
2552 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Execution timed out |
9033 ms |
2552 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |