답안 #867451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
867451 2023-10-28T12:11:24 Z pizzamoeger Zalmoxis (BOI18_zalmoxis) C++14
30 / 100
116 ms 16476 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main () {
	cin.tie(0);
	ios_base::sync_with_stdio(0);

	int n, k; cin >> n >> k;
	vector<int> S (n);
	for (int i = 0; i < n; i++) cin >> S[i];

	assert(k == 1);

	stack<int> nums;
	int insert = -1;
	for (int i = 0; i < n && insert == -1; i++) {
		int cur = S[i];
		while (!nums.empty()) {
			int top = nums.top();
			//cerr << cur << " " << top << " " << i << "\n";
			if (cur == top) {
				cur++;
				nums.pop();
			} else if (cur > top) {
				insert = i;
				break;
			} else break;
		}
		if (insert != -1) break;
		nums.push(cur);
	}
	if (insert == -1) insert = n;
	for (int i = 0; i < n; i++) {
		if (i == insert) cout << nums.top() << " ";
		cout << S[i] << " ";
	}
	if (insert == n) cout << nums.top() << " ";
	cout << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 10320 KB Output is correct
2 Correct 94 ms 10320 KB Output is correct
3 Correct 116 ms 10320 KB Output is correct
4 Correct 92 ms 10324 KB Output is correct
5 Correct 97 ms 10176 KB Output is correct
6 Correct 93 ms 10132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 44 ms 16464 KB Execution killed with signal 6
2 Runtime error 59 ms 16460 KB Execution killed with signal 6
3 Runtime error 44 ms 16212 KB Execution killed with signal 6
4 Runtime error 46 ms 16464 KB Execution killed with signal 6
5 Runtime error 45 ms 16476 KB Execution killed with signal 6
6 Runtime error 56 ms 16476 KB Execution killed with signal 6
7 Runtime error 44 ms 16472 KB Execution killed with signal 6
8 Runtime error 52 ms 16324 KB Execution killed with signal 6
9 Runtime error 40 ms 13136 KB Execution killed with signal 6
10 Runtime error 14 ms 5212 KB Execution killed with signal 6
11 Runtime error 23 ms 8540 KB Execution killed with signal 6
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