Submission #861793

#TimeUsernameProblemLanguageResultExecution timeMemory
861793iskhakkutbilimZalmoxis (BOI18_zalmoxis)C++17
0 / 100
1103 ms48880 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

int n, k;
vector<pair<int, int> > ans;
multiset<int> st;
void f(int x, int depth){
//	cout << x << ' ' << depth << '\n';
	if(x < 0) assert(false);
	int mn = (st.empty() ? INT_MAX : *st.begin());
	if(x > mn){
		f(x-1, depth + 1);
		f(x-1, depth + 1);
	}else{
		ans.push_back({x, depth});
		if(st.count(x))
		st.erase(st.find(x));
	}
}


main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for(int i = 0;i < n; i++){
		int x; cin >> x;
		st.insert(x);
	}
	f(30, 0);
	if(ans.size() != (n + k)){
		assert(false);
	}else{
		for(auto [x, y] : ans) cout << x << ' ';
	}
	return 0;
}

Compilation message (stderr)

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