문제 링크: https://www.acmicpc.net/problem/5957
5957번: Cleaning the Dishes
Bessie and Canmuu are teaming up to wash the massive pile of N (1 <= N <= 10,000) dirty dishes left over after the CowMoose Festival. Bessie is washing the dishes; Canmuu will dry them. Each dish has a unique serial number in the range 1..N. At the beginni
www.acmicpc.net
STACK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include <bits/stdc++.h>
using namespace std;
int n;
stack<int> a, b, c;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = n; i >= 1; i--)
a.push(i);
while(c.size() != n) {
int u, v;
cin >> u >> v;
if(u == 1) {
while(v--) {
b.push(a.top());
a.pop();
}
}
else {
while(v--) {
c.push(b.top());
b.pop();
}
}
}
while(!c.empty()) {
cout << c.top() << '\n';
c.pop();
}
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'USACO > Bronze' 카테고리의 다른 글
백준 5959 Crop Circles (USACO January 2011 Bronze 4번) (0) | 2020.04.08 |
---|---|
백준 5958 Space Exploration (USACO January 2011 Bronze 3번) (0) | 2020.04.08 |
백준 5956 Symmetry (USACO January 2011 Bronze 1번) (0) | 2020.04.08 |
백준 5949 Adding Commas (USACO December 2010 Bronze 3번) (0) | 2020.04.06 |
백준 5948 Bad Random Numbers (USACO December 2010 Bronze 2번) (0) | 2020.04.06 |