답안 #861813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861813 2023-10-17T03:24:18 Z iskhakkutbilim Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
136 ms 12040 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(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 118 ms 11556 KB Unexpected end of file - int32 expected
2 Incorrect 111 ms 10592 KB Unexpected end of file - int32 expected
3 Incorrect 103 ms 10692 KB Unexpected end of file - int32 expected
4 Incorrect 106 ms 11304 KB Unexpected end of file - int32 expected
5 Incorrect 104 ms 10632 KB Unexpected end of file - int32 expected
6 Incorrect 100 ms 11456 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 116 ms 10948 KB Unexpected end of file - int32 expected
2 Incorrect 103 ms 11716 KB Unexpected end of file - int32 expected
3 Incorrect 105 ms 10984 KB Unexpected end of file - int32 expected
4 Incorrect 104 ms 10308 KB Unexpected end of file - int32 expected
5 Incorrect 104 ms 12040 KB Unexpected end of file - int32 expected
6 Incorrect 102 ms 11668 KB Unexpected end of file - int32 expected
7 Incorrect 110 ms 10584 KB Unexpected end of file - int32 expected
8 Incorrect 136 ms 11296 KB Unexpected end of file - int32 expected
9 Incorrect 83 ms 11116 KB Unexpected end of file - int32 expected
10 Incorrect 35 ms 3668 KB Unexpected end of file - int32 expected
11 Incorrect 52 ms 6100 KB Unexpected end of file - int32 expected
12 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
13 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
14 Incorrect 0 ms 344 KB Unexpected end of file - int32 expected