再也不喜欢0了(悲

蒙自市凤凰小学又阝十尃亻二  •  1年前


include <bits/stdc++.h>

using namespace std;

int main() { // freopen("rice.in", "r", stdin); // freopen("rice.out", "w", stdout);

stack<int>a;
stack<int>b;
stack<int>c;
int n1, n2, n3, x, y;
cin >> n1 >> n2 >> n3;
n1 *= 10;
n2 *= 14;
n3 *= 18;
int p = n1 + n2  + n3, ans = 0;
if (p == 0) {//0の特判 第一次没写,90(悲
	cout << 0 << endl;
	return 0;
}
//cout << n1 << " " << n2 << " " << n3 << " " << p;
for (int i = p; i >= 1; i--)
	a.push(i);
while (ans < p) {
	cin >> x >> y;
	if (x == 1) {
		for (int i = 0; i < y; i++) {
			b.push(a.top());
			a.pop();
		}
	} else {
		for (int i = 0; i < y; i++) {
			c.push(b.top());
			b.pop();
		}
		ans += y;
	}
}
while (c.empty() == 0) {
	cout << c.top() << endl;
	c.pop();
}
return 0;

}


评论:

请先登录,才能进行评论