#include "elephants.h"
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
int n,l;
int arr[50100],st[50100];
void init(int N, int L, int X[]){
n = N;
l=L;
for(int i=0;i<N;i++)
st[i]=arr[i]=X[i];
}
int update(int i, int y) {
if(!l)return n;
int ans=0,lst=-1e9;
int p=lower_bound(st,st+n,arr[i])-st;
while(p<n-1&&y>st[p+1])st[p]=st[p+1],p++;
while(p&&y<st[p-1])st[p]=st[p-1],p--;
st[p]=arr[i]=y;
for(int b=0;b<n;b++)
if(lst+l<st[b])
lst=st[b],ans++;
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
606 ms |
1884 KB |
Output is correct |
8 |
Correct |
1401 ms |
2052 KB |
Output is correct |
9 |
Correct |
1318 ms |
3164 KB |
Output is correct |
10 |
Correct |
2563 ms |
2908 KB |
Output is correct |
11 |
Correct |
2594 ms |
2908 KB |
Output is correct |
12 |
Correct |
4611 ms |
2904 KB |
Output is correct |
13 |
Correct |
2721 ms |
2756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
606 ms |
1884 KB |
Output is correct |
8 |
Correct |
1401 ms |
2052 KB |
Output is correct |
9 |
Correct |
1318 ms |
3164 KB |
Output is correct |
10 |
Correct |
2563 ms |
2908 KB |
Output is correct |
11 |
Correct |
2594 ms |
2908 KB |
Output is correct |
12 |
Correct |
4611 ms |
2904 KB |
Output is correct |
13 |
Correct |
2721 ms |
2756 KB |
Output is correct |
14 |
Correct |
1004 ms |
2908 KB |
Output is correct |
15 |
Correct |
3145 ms |
2972 KB |
Output is correct |
16 |
Execution timed out |
9076 ms |
3500 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
606 ms |
1884 KB |
Output is correct |
8 |
Correct |
1401 ms |
2052 KB |
Output is correct |
9 |
Correct |
1318 ms |
3164 KB |
Output is correct |
10 |
Correct |
2563 ms |
2908 KB |
Output is correct |
11 |
Correct |
2594 ms |
2908 KB |
Output is correct |
12 |
Correct |
4611 ms |
2904 KB |
Output is correct |
13 |
Correct |
2721 ms |
2756 KB |
Output is correct |
14 |
Correct |
1004 ms |
2908 KB |
Output is correct |
15 |
Correct |
3145 ms |
2972 KB |
Output is correct |
16 |
Execution timed out |
9076 ms |
3500 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |