#include "elephants.h"
#include<bits/stdc++.h>
using namespace std;
int n,l;
vector<int>v;
void init(int N, int L, int X[])
{
n = N,l=L;
v.resize(n);
for(int i=0;i<n;i++){
v[i]=X[i];
}
}
int update(int i, int y)
{
if(n==1) return 1;
v[i]=y;
sort(v.begin(),v.end());
int xf=v[n-1],pos=v[0],cont=0;
while(pos<=xf){
int s=pos+l+1;
auto it=lower_bound(v.begin(),v.end(),s);
if(it==v.end()){
pos=xf+1;
}
else{
pos=*it;
}
cont++;
//cout<<pos<<"\n";
}
return cont;
}
# | 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... |