답안 #861793

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861793 2023-10-17T03:09:44 Z iskhakkutbilim Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
1000 ms 48880 KB
#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

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)){
      |     ~~~~~~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1035 ms 48680 KB Time limit exceeded
2 Execution timed out 1018 ms 48720 KB Time limit exceeded
3 Execution timed out 1068 ms 48688 KB Time limit exceeded
4 Execution timed out 1028 ms 48680 KB Time limit exceeded
5 Execution timed out 1056 ms 48468 KB Time limit exceeded
6 Execution timed out 1078 ms 48676 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1059 ms 48676 KB Time limit exceeded
2 Execution timed out 1060 ms 48880 KB Time limit exceeded
3 Execution timed out 1070 ms 48836 KB Time limit exceeded
4 Execution timed out 1033 ms 48468 KB Time limit exceeded
5 Execution timed out 1012 ms 48680 KB Time limit exceeded
6 Execution timed out 1101 ms 47188 KB Time limit exceeded
7 Execution timed out 1075 ms 47444 KB Time limit exceeded
8 Execution timed out 1080 ms 47536 KB Time limit exceeded
9 Execution timed out 1066 ms 38020 KB Time limit exceeded
10 Execution timed out 1103 ms 14780 KB Time limit exceeded
11 Execution timed out 1053 ms 24160 KB Time limit exceeded
12 Runtime error 1 ms 604 KB Execution killed with signal 6
13 Runtime error 1 ms 604 KB Execution killed with signal 6
14 Runtime error 1 ms 604 KB Execution killed with signal 6