Submission #365487

#TimeUsernameProblemLanguageResultExecution timeMemory
365487kostia244Zalmoxis (BOI18_zalmoxis)C++17
100 / 100
217 ms18512 KiB
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#include<bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
int n, k;
vector<int> res;
vector<int> st;
vector<array<int, 2>> aa;
void push(int x) {
	while(st.size() && x == st.back()) {
		st.pop_back(), x++;
	}
	st.push_back(x);
}
void uwu(int t) {
	while(st.size() && st.back() < t) {
		aa.push_back({st.back(), 1});
		int x = st.back()+1;
		st.pop_back();
		push(x);
	}
}
void ins(int x, int y) {
	if(!y) {res.push_back(x); return;}
	if(x > 1 && k) {
		k--;
		ins(x-1, 1);
		ins(x-1, 1);
	} else res.push_back(x);
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> k;
	st.reserve(n+k);
	for(int t, i = 0; i < n; i++) {
		cin >> t;
		uwu(t);
		aa.push_back({t, 0});
		push(t);
	}
	uwu(30);
	k = n+k-aa.size();
	for(auto [x, y]  : aa) ins(x, y);
	for(auto i : res) cout << i << " "; cout << endl;
}

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:46:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   46 |  for(auto i : res) cout << i << " "; cout << endl;
      |  ^~~
zalmoxis.cpp:46:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   46 |  for(auto i : res) cout << i << " "; cout << endl;
      |                                      ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...