#include "elephants.h"
#include<cmath>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//int n;
bool s1 = false;
int p[3];
int l;
vector<int> vec;
map<int,int> M;
set<int> s;
void init(int N, int L, int X[])
{
if(N==2) s1= true;
p[0] = X[0];
p[1] = X[1];
for(int i=0; i<N; i++) {
M[i] = X[i];
s.insert(X[i]);
}
//n = N;
l = L;
}
int update(int i, int y)
{
if(s1) {
p[i] = y;
if( (p[0]-p[1]) <=l and (p[0]-p[1]) >=-l ) return 1;
return 2;
}
set<int>::iterator it= s.find(M[i]);
s.erase(it);
s.insert(y);
M[i] = y;
int c = 0;
int pos = -1;
for(it = s.begin(); it!= s.end(); it++) {
if(*it> pos+l or pos==-1) {
c++;
pos = *it;
}
}
return c;
//return n;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
17648 KB |
Output is correct |
2 |
Correct |
0 ms |
17648 KB |
Output is correct |
3 |
Correct |
0 ms |
17648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
17648 KB |
Output is correct |
2 |
Correct |
0 ms |
17648 KB |
Output is correct |
3 |
Correct |
0 ms |
17648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
9000 ms |
18836 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2629 ms |
19364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
9000 ms |
31772 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |