Submission #61910

# Submission time Handle Problem Language Result Execution time Memory
61910 2018-07-27T05:06:48 Z khsoo01 Zalmoxis (BOI18_zalmoxis) C++11
100 / 100
379 ms 10740 KB
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int n, k;

vector<int> cur;
vector<pii> ans;

void upd () {
	while(cur.size() >= 2) {
		int A = cur.back();
		cur.pop_back();
		int B = cur.back();
		cur.pop_back();
		if(A != B) {
			cur.push_back(B);
			cur.push_back(A);
			return;
		}
		else cur.push_back(A+1);
	}
}

void print (int V) {
	if(V && k) {
		k--;
		print(V-1);
		print(V-1);
	}
	else {
		printf("%d ",V);
		return;
	}
}

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) {
		int T;
		scanf("%d",&T);
		while(!cur.empty() && T > cur.back()) {
			ans.push_back({cur.back(), 1});
			k--;
			cur.push_back(cur.back());
			upd();
		}
		ans.push_back({T, 0});
		cur.push_back(T);
		upd();
	}
	while(cur[0] < 30) {
		ans.push_back({cur.back(), 1});
		k--;
		cur.push_back(cur.back());
		upd();
	}
	for(auto &T : ans) {
		int A, B;
		tie(A, B) = T;
		if(B) print(A);
		else printf("%d ",A);
	}
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~
zalmoxis.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&T);
   ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 304 ms 10528 KB Output is correct
2 Correct 291 ms 10528 KB Output is correct
3 Correct 249 ms 10528 KB Output is correct
4 Correct 277 ms 10528 KB Output is correct
5 Correct 312 ms 10608 KB Output is correct
6 Correct 293 ms 10608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 312 ms 10608 KB Output is correct
2 Correct 243 ms 10608 KB Output is correct
3 Correct 379 ms 10740 KB Output is correct
4 Correct 284 ms 10740 KB Output is correct
5 Correct 266 ms 10740 KB Output is correct
6 Correct 265 ms 10740 KB Output is correct
7 Correct 231 ms 10740 KB Output is correct
8 Correct 302 ms 10740 KB Output is correct
9 Correct 330 ms 10740 KB Output is correct
10 Correct 163 ms 10740 KB Output is correct
11 Correct 195 ms 10740 KB Output is correct
12 Correct 116 ms 10740 KB Output is correct
13 Correct 149 ms 10740 KB Output is correct
14 Correct 124 ms 10740 KB Output is correct