Submission #248589

#TimeUsernameProblemLanguageResultExecution timeMemory
248589davi_bartDancing Elephants (IOI11_elephants)C++14
0 / 100
9014 ms1152 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); set<int> k; int dim; vector<int>start; void init(int N, int L, int X[]){ n=N; for(int i=0;i<N;i++){ v[i]=X[i]; k.insert(X[i]); } dim=L; int pos=*k.begin(); start.push_back(pos); for(int x:k){ if(x-pos<=dim)continue; pos=x; start.push_back(pos); } } int update(int i,int y){ int q=min(v[i],y); int ini=lower_bound(start.begin(),start.end(),q)-start.begin(); while(start.size()>ini+1)start.pop_back(); k.erase(v[i]); v[i]=y; k.insert(v[i]); auto it=k.upper_bound(start[ini]); int pos=*it; while(it!=k.end()){ int x=*it; if(x-pos<=dim)continue; pos=x; start.push_back(x); it++; } return start.size(); }

Compilation message (stderr)

elephants.cpp: In function 'int update(int, int)':
elephants.cpp:32:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(start.size()>ini+1)start.pop_back();
         ~~~~~~~~~~~~^~~~~~
#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...