#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;
int n;
vector <int> ap;
vector <int> pe;
int c;
void init(int N, int L, int X[]){
n=N;
c=L;
ap.resize(n);
pe.resize(n);
for(int i=0; i<n; ++i){
pe[i]=X[i];
ap[i]=X[i];
}
sort(pe.begin(), pe.end());
}
int update(int i, int y){
int cnt=0;
for(int j=0; j<n; ++j){
if(pe[j]==ap[i]){
pe.erase(pe.begin()+j, pe.begin()+j+1);
break;
}
}
pe.push_back(y);
for(int j=n-2; j>=0; --j){
if(pe[j]>pe[j+1]){
int aux=pe[j];
pe[j]=pe[j+1];
pe[j+1]=aux;
}
else if(pe[j]==ap[j+1]){
int aguss=pe[j];
pe[j]=pe[j+1];
pe[j+1]=aguss;
break;
}
else{
break;
}
}
ap[i]=y;
int cp=-1;
for(int j=0; j<n; ++j){
if(cp==-1 || cp+c<pe[j]){
++cnt;
cp=pe[j];
}
}
return cnt;
}
# | 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... |