This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "elephants.h"
using namespace std;
typedef long long ll;
//#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
vector<int> v(200010);
vector<int> p(200010);
int dim;
void init(int N, int L, int X[]){
n=N;
v.resize(N);
p.resize(N);
for(int i=0;i<N;i++){
p[i]=v[i]=X[i];
}
dim=L;
}
int update(int i,int y){
p.erase(lower_bound(p.begin(),p.end(),v[i]));
p.insert(upper_bound(p.begin(),p.end(),y),y);
v[i]=y;
int pos=p[0];
int tot=1;
for(int i=0;i<n;i++){
if(p[i]-pos>dim){
tot++;
pos=p[i];
}
int d=2;
while(i<n-1){
d=min(d,n-i-1);
if(p[i+d]-pos<=dim){
i+=d;
d*=2;
}else break;
}
}
return tot;
}
# | 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... |