Submission #856056

#TimeUsernameProblemLanguageResultExecution timeMemory
856056BenmathZalmoxis (BOI18_zalmoxis)C++14
30 / 100
604 ms22452 KiB
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <bits/stdc++.h> using namespace std; int niz[1000001]; int n; int k; int vis[1000001]; using pii = pair<int,pair<int,int>>; int main() { cin >> n >> k; priority_queue<pii, vector<pii> , greater<pii> > pq; for(int i = 0; i < n; i++){ cin >> niz[i]; pq.push({niz[i],{i,i}}); } int ans = -1; int ind = -1; int t1 = 0; while(!pq.empty() and t1 == 0){ pii a = pq.top(); pq.pop(); if(pq.empty()){ ans = a.first; ind = a.second.second; t1++; break; }else{ pii b = pq.top(); pq.pop(); if(a.first != b.first){ ans = a.first; ind = a.second.second; t1++; break; }else{ int prvi = a.second.second + 1; int drugi = b.second.first; if(prvi == drugi){ pq.push({a.first + 1,{a.second.first,b.second.second}}); }else{ ans = a.first; ind = a.second.second; t1++; break; } } } } for(int i = 0; i < n; i++){ cout << niz[i] << " "; if(ind == i){ cout << ans << " "; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...