#include<bits/stdc++.h>
using namespace std;
int n, lg;
int vals[150002], srt[150002];
void init(int N, int L, int X[])
{
n = N;
lg = L;
for(int i = 1; i <= N; ++i)
srt[i] = X[i-1], vals[i] = X[i-1];
sort(srt + 1, srt + n + 1);
srt[n+1] = 2100000000;
}
int binsearch(int val)
{
int st = 1;
int dr = n;
int ans = 0;
while(st <= dr)
{
int mid = (st + dr) / 2;
if(srt[mid] <= val)
ans = mid, st = mid + 1;
else
dr = mid - 1;
}
return ans;
}
int nw[150002];
int update(int xx, int y)
{
++xx;
if(n == 2)
{
vals[xx] = y;
if(abs(vals[1] - vals[2]) > lg)
return 2;
return 1;
}
int aa = 0;
if(y == vals[xx]);
else
{
if(y > vals[xx])
{
int pz = binsearch(y);
if(srt[pz] == vals[xx]);
else
{
nw[pz-1] = y;
int pp = 1;
for(int i = 1; i <= n; ++i)
{
if(srt[i] == vals[xx])
continue;
nw[pp++] = srt[i];
if(pp == pz-1)
++pp;
}
}
vals[xx] = y;
}
else
{
aa = 1;
int yy = y;
for(int i = 1; i <= n; ++i)
{
if(srt[i] == vals[xx])
continue;
if(yy <= srt[i])
nw[aa++] = yy, yy = 2100000000;
nw[aa++] = srt[i];
}
vals[xx] = y;
}
}
for(int i = 1; i <= n; ++i)
srt[i] = nw[i];
int ans = 0;
int st = 0;
for(int i = 1; i <= n;)
{
++ans;
st = srt[i];
while(i <= n && srt[i] - st <= lg)
++i;
}
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 |
372 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 |
372 KB |
Output is correct |
4 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
5 |
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 |
372 KB |
Output is correct |
4 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
5 |
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 |
372 KB |
Output is correct |
4 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
5 |
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 |
372 KB |
Output is correct |
4 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |