#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)1.5e5+10;
const int B = 240;
set<int> S;
int n, L, ok, p[mxN/B];
unordered_map<int,int> b;
vector<pair<int,int>> block[mxN/B];
void ins(int x){
b[x]++; if(b[x]!=1) return;
if(ok) { S.insert(x); return; }
}
void del(int x){
b[x]--; if(b[x]) return;
if(ok) { S.erase(x); return;}
}
void init(int N, int l, int X[])
{
n = N; L = l;
if(L > mxN/B or 1) ok=1;
for(int i = 0; i < n; i++)
p[i]=X[i], ins(p[i]);
}
int update(int i, int y)
{
del(p[i]); p[i]=y; ins(y);
int ans = 0;
if(ok){
auto itr = S.begin();
while(itr!=S.end()) itr = S.upper_bound(*itr+L), ans++;
return ans;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Runtime error |
15 ms |
2712 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Runtime error |
15 ms |
2712 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Runtime error |
15 ms |
2712 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |