Submission #867450

#TimeUsernameProblemLanguageResultExecution timeMemory
867450pizzamoegerZalmoxis (BOI18_zalmoxis)C++14
10 / 100
101 ms18516 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-1; for (int i = 0; i < n; i++) { if (i == insert) cout << nums.top() << " "; cout << S[i] << " "; } cout << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...