Submission #867483

#TimeUsernameProblemLanguageResultExecution timeMemory
867483pizzamoegerZalmoxis (BOI18_zalmoxis)C++14
40 / 100
114 ms20164 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]; stack<int> nums; vector<pair<int,int>> inserts; int i = 0; while (i < n) { 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) { inserts.push_back({i, top}); cur = top+1; nums.pop(); i--; } else { nums.push(cur); break; } } if (nums.empty()) nums.push(cur); i++; } if (!nums.empty() && nums.top() != 30) inserts.push_back({n, nums.top()}); int left = k-inserts.size(); int j = 0; while (left > 0) { while (inserts[j].second == 0) j++; inserts[j].second--; inserts.push_back(inserts[j]); left--; } sort(inserts.begin(), inserts.end()); j = 0; for (int i = 0; i < n; i++) { while (j < inserts.size() && i == inserts[j].first) { int cnt = inserts[j].second; cout << cnt << " "; j++; } cout << S[i] << " "; } while (j < inserts.size() && n == inserts[j].first) { int cnt = inserts[j].second; cout << cnt << " "; j++; } cout << "\n"; } /* while (left > 1 && cnt > 1) { cnt--; cout << cnt << " "; left--; } if (left >= 1) { cout << cnt-1 << " " << cnt-1 << " "; left--; } else */

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:54:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   while (j < inserts.size() && i == inserts[j].first) {
      |          ~~^~~~~~~~~~~~~~~~
zalmoxis.cpp:61:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |  while (j < inserts.size() && n == inserts[j].first) {
      |         ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...