#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 |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
1 ms |
8540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
1 ms |
8540 KB |
Output is correct |
4 |
Correct |
1 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8536 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
1 ms |
8540 KB |
Output is correct |
4 |
Correct |
1 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8536 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
639 ms |
10588 KB |
Output is correct |
8 |
Correct |
1443 ms |
10588 KB |
Output is correct |
9 |
Correct |
1362 ms |
10844 KB |
Output is correct |
10 |
Correct |
2561 ms |
10852 KB |
Output is correct |
11 |
Correct |
2595 ms |
12128 KB |
Output is correct |
12 |
Correct |
4687 ms |
12284 KB |
Output is correct |
13 |
Correct |
2834 ms |
11984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
1 ms |
8540 KB |
Output is correct |
4 |
Correct |
1 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8536 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
639 ms |
10588 KB |
Output is correct |
8 |
Correct |
1443 ms |
10588 KB |
Output is correct |
9 |
Correct |
1362 ms |
10844 KB |
Output is correct |
10 |
Correct |
2561 ms |
10852 KB |
Output is correct |
11 |
Correct |
2595 ms |
12128 KB |
Output is correct |
12 |
Correct |
4687 ms |
12284 KB |
Output is correct |
13 |
Correct |
2834 ms |
11984 KB |
Output is correct |
14 |
Correct |
1018 ms |
12256 KB |
Output is correct |
15 |
Correct |
3371 ms |
12180 KB |
Output is correct |
16 |
Execution timed out |
9060 ms |
12636 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
1 ms |
8540 KB |
Output is correct |
4 |
Correct |
1 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8536 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
639 ms |
10588 KB |
Output is correct |
8 |
Correct |
1443 ms |
10588 KB |
Output is correct |
9 |
Correct |
1362 ms |
10844 KB |
Output is correct |
10 |
Correct |
2561 ms |
10852 KB |
Output is correct |
11 |
Correct |
2595 ms |
12128 KB |
Output is correct |
12 |
Correct |
4687 ms |
12284 KB |
Output is correct |
13 |
Correct |
2834 ms |
11984 KB |
Output is correct |
14 |
Correct |
1018 ms |
12256 KB |
Output is correct |
15 |
Correct |
3371 ms |
12180 KB |
Output is correct |
16 |
Execution timed out |
9060 ms |
12636 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |