#include <bits/stdc++.h>
using namespace std;
#include "elephants.h"
int n;
int l;
vector<int> v;
vector<int> v2;
vector<int> ind;
list<int> ls;
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());
for(auto i:v) ls.push_back(i);
}
int update(int j, int y)
{
bool er=1;
bool ins=1;
for(auto i=ls.begin(); i!=ls.end();){
if(ins && *i>=y){
ls.insert(i, y);
ins=0;
}
if(er&& *i==ind[j]){
i=ls.erase(i);
er=0;
}
else i++;
}
if(ins) ls.push_back(y);
ind[j]=y;
int res=0;
int mx=-10000000;
for(auto i:ls){
if(i>mx){
mx=i+l;
res++;
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
2120 ms |
1496 KB |
Output is correct |
8 |
Correct |
3512 ms |
1748 KB |
Output is correct |
9 |
Execution timed out |
9039 ms |
3268 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
2120 ms |
1496 KB |
Output is correct |
8 |
Correct |
3512 ms |
1748 KB |
Output is correct |
9 |
Execution timed out |
9039 ms |
3268 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
2120 ms |
1496 KB |
Output is correct |
8 |
Correct |
3512 ms |
1748 KB |
Output is correct |
9 |
Execution timed out |
9039 ms |
3268 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |