This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |