Submission #862143

# Submission time Handle Problem Language Result Execution time Memory
862143 2023-10-17T14:42:06 Z iskhakkutbilim Zalmoxis (BOI18_zalmoxis) C++17
100 / 100
191 ms 22452 KB
#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> all;
void split(int x){
	if(k == 0 or x == 0){
		all.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;
	for(auto [x, y] : ans){
		if(!y){
			all.push_back(x);
			continue;
		}
		split(x);
	}
	for(int x : all) cout << x << ' ';
	return 0;
}

Compilation message

zalmoxis.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main(){
      | ^~~~
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:45: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]
   45 |  if(ans.size() == n + k){
      |     ~~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 173 ms 14260 KB Output is correct
2 Correct 174 ms 14620 KB Output is correct
3 Correct 177 ms 14176 KB Output is correct
4 Correct 185 ms 14172 KB Output is correct
5 Correct 178 ms 14436 KB Output is correct
6 Correct 172 ms 14160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 177 ms 22108 KB Output is correct
2 Correct 172 ms 14256 KB Output is correct
3 Correct 188 ms 22192 KB Output is correct
4 Correct 177 ms 22196 KB Output is correct
5 Correct 183 ms 22196 KB Output is correct
6 Correct 191 ms 22452 KB Output is correct
7 Correct 178 ms 22352 KB Output is correct
8 Correct 183 ms 22192 KB Output is correct
9 Correct 190 ms 21800 KB Output is correct
10 Correct 100 ms 13304 KB Output is correct
11 Correct 122 ms 17844 KB Output is correct
12 Correct 57 ms 6328 KB Output is correct
13 Correct 58 ms 6324 KB Output is correct
14 Correct 58 ms 6328 KB Output is correct