Submission #862082

# Submission time Handle Problem Language Result Execution time Memory
862082 2023-10-17T13:55:09 Z iskhakkutbilim Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
1000 ms 6612 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<int> ans;
int cur;
vector<int> a;
void f(int x, int depth){
	if(x <= 0) return;
	if(cur > n) return;
	if(cur >= n or a[cur] >= x){
		ans.push_back(x);
		if(a[cur] == x) cur++;
//		cur++;
	}else{
		f(x-1, depth + 1);
		f(x-1, depth + 1);
	}
	
}


main(){
	cin >> n >> k;
	a.resize(n);
	for(int i = 0;i < n; i++){
		cin >> a[i];
	}
	/*
	5 1
	28 25 25 26 27
	
	6 1
	28 25 25 26 27 29
	
	5 1
	28  25 26 27 29
	*/
	f(30, 1);
	if(ans.size() == n + k){
		for(int x : ans) cout << x << ' ';
		return 0;
	}
	if(ans.back() > 1){
		int bk = ans.back();
		ans.pop_back();
		ans.push_back(bk-1);
		ans.push_back(bk-1);
		for(int x : ans) cout << x << ' ';
	}else if(ans[0] > 1){
		int bk = ans[0];
		cout << bk-1 << ' ' << bk-1 << ' ';
		for(int i = 1;i < ans.size(); i++) cout << ans[i] << ' ';
	}else{
		assert(false);
	}
//	while(ans.size() < n + k){
//		vector<int> have = ans;
//		vector<int> merge;
//		ans.clear();
//		for(int i = 0;i < have.size(); i++){
//			if(have[i] > 1){
//				f(have[i]-1, 1);
//				f(have[i]-1, 1);
//				for(int j = 0;j < i; j++) merge.push_back(have[j]);
//				for(int x : ans) merge.push_back(x);
//				for(int j = i + 1; j < have.size(); j++){
//					merge.push_back(have[j]);
//				}
//				break;
//			}
//		}
//		if(merge.empty()) assert(false);
//		ans = merge;
//	}
//	for(int i = 0;i < ans.size(); i++) cout << ans[i] << ' ';
	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:44:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |  if(ans.size() == n + k){
      |     ~~~~~~~~~~~^~~~~~~~
zalmoxis.cpp:57:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |   for(int i = 1;i < ans.size(); i++) cout << ans[i] << ' ';
      |                 ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1027 ms 6224 KB Time limit exceeded
2 Execution timed out 1068 ms 6252 KB Time limit exceeded
3 Execution timed out 1045 ms 6228 KB Time limit exceeded
4 Execution timed out 1027 ms 6236 KB Time limit exceeded
5 Execution timed out 1065 ms 6236 KB Time limit exceeded
6 Execution timed out 1071 ms 6368 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1046 ms 6224 KB Time limit exceeded
2 Execution timed out 1026 ms 6224 KB Time limit exceeded
3 Execution timed out 1033 ms 6612 KB Time limit exceeded
4 Execution timed out 1010 ms 6368 KB Time limit exceeded
5 Execution timed out 1060 ms 6380 KB Time limit exceeded
6 Execution timed out 1062 ms 6384 KB Time limit exceeded
7 Execution timed out 1055 ms 6228 KB Time limit exceeded
8 Execution timed out 1028 ms 6224 KB Time limit exceeded
9 Execution timed out 1073 ms 5068 KB Time limit exceeded
10 Execution timed out 1063 ms 2132 KB Time limit exceeded
11 Execution timed out 1037 ms 3412 KB Time limit exceeded
12 Execution timed out 1064 ms 348 KB Time limit exceeded
13 Execution timed out 1004 ms 344 KB Time limit exceeded
14 Incorrect 1 ms 348 KB Unexpected end of file - int32 expected