#include "elephants.h"
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
int n,l;
int arr[50100],ps[50100],st[50100];
void init(int N, int L, int X[]){
n = N;
l=L;
for(int i=0;i<N;i++)
st[i]=ps[i]=i,arr[i]=X[i];
}
int update(int i, int y) {
if(!l)return n;
int ans=0,lst=-1e9;
arr[i]=y;
while(ps[i]<n-1&&arr[i]>arr[st[ps[i]+1]])
swap(ps[i],ps[st[ps[i]+1]]),swap(st[ps[i]],st[ps[i]-1]);
while(ps[i]&&arr[i]<arr[st[ps[i]-1]])
swap(ps[i],ps[st[ps[i]-1]]),swap(st[ps[i]],st[ps[i]+1]);
for(int b=0;b<n;b++)
if(lst+l<arr[st[b]])
lst=arr[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 |
2 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 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 |
2 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
630 ms |
8668 KB |
Output is correct |
8 |
Correct |
1721 ms |
8540 KB |
Output is correct |
9 |
Correct |
1450 ms |
10852 KB |
Output is correct |
10 |
Execution timed out |
9037 ms |
12080 KB |
Time limit exceeded |
11 |
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 |
2 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
630 ms |
8668 KB |
Output is correct |
8 |
Correct |
1721 ms |
8540 KB |
Output is correct |
9 |
Correct |
1450 ms |
10852 KB |
Output is correct |
10 |
Execution timed out |
9037 ms |
12080 KB |
Time limit exceeded |
11 |
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 |
2 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
630 ms |
8668 KB |
Output is correct |
8 |
Correct |
1721 ms |
8540 KB |
Output is correct |
9 |
Correct |
1450 ms |
10852 KB |
Output is correct |
10 |
Execution timed out |
9037 ms |
12080 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |