Submission #862142

#TimeUsernameProblemLanguageResultExecution timeMemory
862142iskhakkutbilimZalmoxis (BOI18_zalmoxis)C++17
100 / 100
196 ms24380 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define all(a) a.begin(), a.end() int n, k; vector<pair<int, int> > ans; int cur; vector<int> a; void f(int x){ if(x < 0) return; if(cur >= n or a[cur] >= x){ if(cur < n && a[cur] == x){ ans.push_back({x, 0}); cur++; }else{ ans.push_back({x, 1}); } }else{ f(x-1); f(x-1); } } vector<int> add; void split(int x){ if(k == 0 or x == 0){ add.push_back(x); }else{ k--; split(x-1); split(x-1); } } main(){ cin >> n >> k; a.resize(n); for(int i = 0;i < n; i++){ cin >> a[i]; } f(30); if(ans.size() == n + k){ for(auto [x, y] : ans) cout << x << ' '; return 0; } k = k - (int)ans.size() + n; vector<int> all; for(auto [x, y] : ans){ if(!y){ all.push_back(x); continue; } add.clear(); split(x); for(int ax : add) all.push_back(ax); } for(int x : all) cout << x << ' '; return 0; }

Compilation message (stderr)

zalmoxis.cpp:38:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   38 | main(){
      | ^~~~
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:46:16: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |  if(ans.size() == n + k){
      |     ~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...