#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;
int res=0;
long long last=-100000000;
for(int j=0; j<n; j++){
if(j==insind){
v2[j+shift]=y;
shift+=1;
if(y>last){
last=y+l;
res++;
}
}
if(j==erind){
shift-=1;
continue;
}
v2[j+shift]=v[j];
if(j==n && shift==-1) v2[n-1]=y;
auto&x =v2[shift+j];
if(x>last){
last=x+l;
res++;
}
}
swap(v,v2);
ind[i]=y;
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |