Submission #861808

# Submission time Handle Problem Language Result Execution time Memory
861808 2023-10-17T03:21:21 Z iskhakkutbilim Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
144 ms 10804 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';
if(x <= 0) assert(false);
	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:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   28 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 8904 KB Unexpected end of file - int32 expected
2 Incorrect 105 ms 9156 KB Unexpected end of file - int32 expected
3 Incorrect 102 ms 10180 KB Unexpected end of file - int32 expected
4 Incorrect 133 ms 9012 KB Unexpected end of file - int32 expected
5 Incorrect 103 ms 9528 KB Unexpected end of file - int32 expected
6 Incorrect 99 ms 9668 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 10180 KB Unexpected end of file - int32 expected
2 Incorrect 114 ms 9004 KB Unexpected end of file - int32 expected
3 Incorrect 108 ms 10536 KB Unexpected end of file - int32 expected
4 Incorrect 144 ms 10440 KB Unexpected end of file - int32 expected
5 Incorrect 106 ms 10804 KB Unexpected end of file - int32 expected
6 Incorrect 104 ms 9776 KB Unexpected end of file - int32 expected
7 Incorrect 106 ms 9928 KB Unexpected end of file - int32 expected
8 Incorrect 115 ms 9524 KB Unexpected end of file - int32 expected
9 Incorrect 86 ms 10440 KB Unexpected end of file - int32 expected
10 Incorrect 32 ms 3132 KB Unexpected end of file - int32 expected
11 Incorrect 57 ms 5936 KB Unexpected end of file - int32 expected
12 Incorrect 0 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