Submission #1144411

#TimeUsernameProblemLanguageResultExecution timeMemory
1144411not_amirZalmoxis (BOI18_zalmoxis)C++20
35 / 100
78 ms2536 KiB
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, k; cin >> n >> k; stack<int> stk; for (int i = 0; i < n; i++) { int x; cin >> x; int prev = -1; while (!stk.empty() && stk.top() < x) { if (prev == -1) prev = stk.top(); else { for (int idx = prev; idx < stk.top(); idx++) cout << idx << ' '; prev = stk.top() + 1; } stk.pop(); } if (prev != -1) { for (int idx = prev; idx < x; idx++) cout << idx << ' '; int tx = x; while (!stk.empty() && stk.top() == tx) { stk.pop(); tx++; } stk.push(tx); } cout << x << ' '; while (!stk.empty() && stk.top() == x) { stk.pop(); x++; } stk.push(x); } int prev = -1; while (!stk.empty()) { if (prev == -1) prev = stk.top(); else { for (int idx = prev; idx < stk.top(); idx++) cout << idx << ' '; prev = stk.top() + 1; } stk.pop(); } for (int idx = prev; idx < 30; idx++) cout << idx << ' '; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...