Submission #867451

#TimeUsernameProblemLanguageResultExecution timeMemory
867451pizzamoegerZalmoxis (BOI18_zalmoxis)C++14
30 / 100
116 ms16476 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main () { cin.tie(0); ios_base::sync_with_stdio(0); int n, k; cin >> n >> k; vector<int> S (n); for (int i = 0; i < n; i++) cin >> S[i]; assert(k == 1); stack<int> nums; int insert = -1; for (int i = 0; i < n && insert == -1; i++) { int cur = S[i]; while (!nums.empty()) { int top = nums.top(); //cerr << cur << " " << top << " " << i << "\n"; if (cur == top) { cur++; nums.pop(); } else if (cur > top) { insert = i; break; } else break; } if (insert != -1) break; nums.push(cur); } if (insert == -1) insert = n; for (int i = 0; i < n; i++) { if (i == insert) cout << nums.top() << " "; cout << S[i] << " "; } if (insert == n) cout << nums.top() << " "; cout << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...