Submission #602324

# Submission time Handle Problem Language Result Execution time Memory
602324 2022-07-22T22:02:51 Z UncoolAnon Zalmoxis (BOI18_zalmoxis) C++14
35 / 100
155 ms 10488 KB
#include <bits/stdc++.h> 

#define pii pair<int,int> 
#define F first 
#define S second 
#define mp make_pair 

using namespace std; 
 

signed main(){
	ios_base::sync_with_stdio(0); 
	cin.tie(nullptr); 
	int n,k; 
	cin>>n>>k; 
	vector<int> a(n); 
	for(int&x:a) cin>>x; 
	int answer=(1<<30); 
	for(int&x:a) answer-=(1<<x); 
	vector<int> added,ones; 
	for(int i=0;i<30;i++)
		if((1<<i)&answer){
			added.push_back(i); 
		}

	while(added.size()+ones.size()<k){
		if(added.back()==0){
			added.pop_back(); 
			ones.push_back(0); 
		}
		else{
			int tmp=added.back(); 
			added.pop_back(); 
			added.push_back(tmp-1); 
			added.push_back(tmp-1); 
		}
	}
	vector<int> ans; 
	for(int&x:a) ans.push_back(x); 
	for(int&x:added) ans.push_back(x); 
	for(int&x:ones) ans.push_back(x); 
	for(int&x:ans) cout << x << " " ; 
	return 0 ; 
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:26:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |  while(added.size()+ones.size()<k){
      |        ~~~~~~~~~~~~~~~~~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 121 ms 10428 KB Output is correct
2 Correct 110 ms 10304 KB Output is correct
3 Correct 113 ms 10428 KB Output is correct
4 Correct 107 ms 10376 KB Output is correct
5 Correct 123 ms 10368 KB Output is correct
6 Correct 111 ms 10308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 130 ms 10356 KB not a zalsequence
2 Incorrect 111 ms 10376 KB not a zalsequence
3 Incorrect 111 ms 10384 KB not a zalsequence
4 Incorrect 106 ms 10304 KB not a zalsequence
5 Incorrect 155 ms 10352 KB not a zalsequence
6 Incorrect 113 ms 10488 KB not a zalsequence
7 Incorrect 109 ms 10356 KB not a zalsequence
8 Incorrect 110 ms 10344 KB not a zalsequence
9 Incorrect 107 ms 10340 KB not a zalsequence
10 Incorrect 86 ms 10348 KB not a zalsequence
11 Incorrect 94 ms 10212 KB not a zalsequence
12 Incorrect 68 ms 10312 KB not a zalsequence
13 Incorrect 69 ms 10356 KB not a zalsequence
14 Correct 70 ms 10312 KB Output is correct