Submission #861807

# Submission time Handle Problem Language Result Execution time Memory
861807 2023-10-17T03:20:30 Z iskhakkutbilim Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
140 ms 12744 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 st[31];
void f(int x, int depth){
//	cout << x << ' ' << depth << '\n';
	int mn = 1;
	while(st[mn] <= 0 && x >= mn) mn++;
//	cout << mn << '\n';
	if(x > mn){
		f(x-1, depth + 1);
		f(x-1, depth + 1);
	}else{
		ans.push_back({x, depth});
		st[x]--;
//		cout << "del " << x << '\n';
	}
}


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[x]++;
	}
	f(30, 0);
//	if(ans.size() != (n + k)){
//		assert(false);
//	}else{
		sort(all(ans), [&](pair<int, int> A, pair<int, int> B){
			return A.ss < B.ss;	
		});
		for(auto [x, y] : ans) cout << x << ' ';
//	}
	return 0;
}

Compilation message

zalmoxis.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   27 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 119 ms 11412 KB Unexpected end of file - int32 expected
2 Incorrect 120 ms 12484 KB Unexpected end of file - int32 expected
3 Incorrect 121 ms 11208 KB Unexpected end of file - int32 expected
4 Incorrect 115 ms 11208 KB Unexpected end of file - int32 expected
5 Incorrect 115 ms 11464 KB Unexpected end of file - int32 expected
6 Incorrect 121 ms 12228 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 113 ms 10956 KB Unexpected end of file - int32 expected
2 Incorrect 111 ms 12572 KB Unexpected end of file - int32 expected
3 Incorrect 115 ms 12584 KB Unexpected end of file - int32 expected
4 Incorrect 140 ms 11424 KB Unexpected end of file - int32 expected
5 Incorrect 130 ms 12560 KB Unexpected end of file - int32 expected
6 Incorrect 133 ms 11464 KB Unexpected end of file - int32 expected
7 Incorrect 117 ms 11208 KB Unexpected end of file - int32 expected
8 Incorrect 118 ms 12744 KB Unexpected end of file - int32 expected
9 Incorrect 96 ms 10436 KB Unexpected end of file - int32 expected
10 Incorrect 35 ms 3788 KB Unexpected end of file - int32 expected
11 Incorrect 69 ms 7548 KB Unexpected end of file - int32 expected
12 Incorrect 1 ms 344 KB Unexpected end of file - int32 expected
13 Incorrect 1 ms 348 KB Unexpected end of file - int32 expected
14 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected