#include <bits/stdc++.h>
using namespace std;
#include "elephants.h"
int n;
int l;
vector<int> v;
vector<int> v2;
vector<int> ind;
void init(int N, int L, int X[])
{
n = N;
l=L;
ind.resize(n);
v2.resize(n);
for(int i=0; i<n; i++){
v.push_back(X[i]);
ind[i]=X[i];
}
sort(v.begin(), v.end());
}
int update(int i, int y)
{
int erind=(lower_bound(v.begin(), v.end(), ind[i]))-v.begin();
int insind=upper_bound(v.begin(), v.end(), y)-v.begin();
int shift=0;
for(int j=0; j<n; j++){
if(j==insind){
v2[j+shift]=y;
shift+=1;
}
if(j==erind){
shift-=1;
continue;
}
v2[j+shift]=v[j];
}
if(shift==-1) v2[n-1]=y;
swap(v,v2);
ind[i]=y;
int res=0;
long long last=-100000000;
for(auto i:v){
if(i>last){
last=i+l;
res++;
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
1725 ms |
2064 KB |
Output is correct |
8 |
Correct |
3063 ms |
2340 KB |
Output is correct |
9 |
Correct |
4131 ms |
3404 KB |
Output is correct |
10 |
Correct |
4130 ms |
3148 KB |
Output is correct |
11 |
Correct |
4086 ms |
3156 KB |
Output is correct |
12 |
Correct |
8042 ms |
3276 KB |
Output is correct |
13 |
Correct |
4200 ms |
3028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
1725 ms |
2064 KB |
Output is correct |
8 |
Correct |
3063 ms |
2340 KB |
Output is correct |
9 |
Correct |
4131 ms |
3404 KB |
Output is correct |
10 |
Correct |
4130 ms |
3148 KB |
Output is correct |
11 |
Correct |
4086 ms |
3156 KB |
Output is correct |
12 |
Correct |
8042 ms |
3276 KB |
Output is correct |
13 |
Correct |
4200 ms |
3028 KB |
Output is correct |
14 |
Correct |
2197 ms |
3080 KB |
Output is correct |
15 |
Correct |
6185 ms |
3148 KB |
Output is correct |
16 |
Execution timed out |
9012 ms |
3828 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
1725 ms |
2064 KB |
Output is correct |
8 |
Correct |
3063 ms |
2340 KB |
Output is correct |
9 |
Correct |
4131 ms |
3404 KB |
Output is correct |
10 |
Correct |
4130 ms |
3148 KB |
Output is correct |
11 |
Correct |
4086 ms |
3156 KB |
Output is correct |
12 |
Correct |
8042 ms |
3276 KB |
Output is correct |
13 |
Correct |
4200 ms |
3028 KB |
Output is correct |
14 |
Correct |
2197 ms |
3080 KB |
Output is correct |
15 |
Correct |
6185 ms |
3148 KB |
Output is correct |
16 |
Execution timed out |
9012 ms |
3828 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |