Submission #248594

#TimeUsernameProblemLanguageResultExecution timeMemory
248594davi_bartDancing Elephants (IOI11_elephants)C++14
26 / 100
9076 ms2808 KiB
#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; if(dim>1000000){ while(1){ int w=upper_bound(p.begin(),p.end(),pos+dim)-p.begin(); if(w==p.size())break; tot++; pos=p[w]; } }else{ for(int x:p){ if(x-pos<=dim)continue; tot++; pos=x; } } return tot; } /* 4 10 10 15 17 20 2 16 1 25 3 35 0 38 2 0 */

Compilation message (stderr)

elephants.cpp: In function 'int update(int, int)':
elephants.cpp:30:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if(w==p.size())break;
          ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...