Submission #977287

#TimeUsernameProblemLanguageResultExecution timeMemory
977287alexddZalmoxis (BOI18_zalmoxis)C++17
0 / 100
1077 ms188448 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int n,k; set<pair<int,int>> init; set<pair<int,pair<int,int>>> s; set<pair<pair<int,int>,int>> s2; signed main() { cin>>n>>k; int a; for(int i=1;i<=n;i++) { cin>>a; int cv = 1000005LL*i; init.insert({cv,a}); s.insert({a,{cv,cv}}); s2.insert({{cv,cv},a}); } while((int)s.size()>1 && k>=0) { pair<int,pair<int,int>> aux = *s.begin(); int val = aux.first; int le = aux.second.first; int ri = aux.second.second; auto it = s2.lower_bound({{le,ri},val}); if(next(it)!=s2.end() && (*next(it)).second==val) { int le2 = (*next(it)).first.first; int ri2 = (*next(it)).first.second; s.insert({val+1,{le,ri2}}); s2.insert({{le,ri2},val+1}); s.erase({val,{le2,ri2}}); s2.erase({{le2,ri2},val}); s.erase({val,{le,ri}}); s2.erase({{le,ri},val}); } else { k--; init.insert({ri+1,val}); s.insert({val+1,{le,ri+1}}); s2.insert({{le,ri+1},val+1}); s.erase({val,{le,ri}}); s2.erase({{le,ri},val}); } } if(k>0) { int le = (*s.begin()).second.first; int ri = (*s.begin()).second.second; int val = (*s.begin()).first; if(k==1) { init.insert({ri+1,val}); } else { } } for(auto x:init) { cout<<x.second<<" "; } return 0; }

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:55:13: warning: unused variable 'le' [-Wunused-variable]
   55 |         int le = (*s.begin()).second.first;
      |             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...