85752024-01-22 11:50:46IgnácTáblajáték 2 (70 pont)cpp17Runtime error 8/706ms5212 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, sor = 0;
	cin >> n;
	string elem = "";
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a == 0) {
			sor++;
			elem += "0";
		}
		if (a == 1) {
			sor++;
			elem += "1";
		}
		if (a == 2) {
			sor++;
			elem += "2";
		}
		if (a == 3) {
			sor--;
			elem.pop_back();
		}
		if (a == 4) {
			int j = elem.size() - 1;
			while (elem[j] == '0') {
				elem[j] = '2';
				j--;
			}
			elem[j]--;
		}
		if (a == 5) {
			int j = elem.size() - 1;
			while (elem[j] == '2') {
				elem[j] = '0';
				j--;
			}
			elem[j]++;
		}
	}

	cout << sor << "\n";
	if (elem == "") cout << "0";
	else cout << stoi(elem);
}
SubtaskSumTestVerdictTimeMemory
base8/70
1Accepted0/03ms1964 KiB
2Runtime error0/04ms2580 KiB
3Accepted2/23ms2296 KiB
4Runtime error0/34ms2924 KiB
5Accepted3/33ms2596 KiB
6Runtime error0/34ms3100 KiB
7Runtime error0/34ms3356 KiB
8Runtime error0/34ms3320 KiB
9Runtime error0/34ms3388 KiB
10Runtime error0/36ms3648 KiB
11Runtime error0/34ms3976 KiB
12Runtime error0/34ms4296 KiB
13Runtime error0/34ms4264 KiB
14Runtime error0/34ms4492 KiB
15Runtime error0/44ms4296 KiB
16Runtime error0/46ms4468 KiB
17Runtime error0/46ms4584 KiB
18Runtime error0/46ms4792 KiB
19Runtime error0/44ms4664 KiB
20Runtime error0/44ms4924 KiB
21Runtime error0/46ms5144 KiB
22Runtime error0/44ms5212 KiB
23Accepted3/33ms4808 KiB