forked from tony9402/baekjoon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
51 lines (41 loc) · 1.08 KB
/
main.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
// Authored by : tallua_y
// Co-authored by :
// Link : http://boj.kr/98f5daa8e3a3430cb4a5998327fd56cf
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv)
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
int remain = 1;
vector<int> stack;
stack.reserve(N);
vector<char> answer;
answer.reserve(2 * N + 1);
for (int n = 0; n < N; ++n) {
int current;
cin >> current;
while (remain <= current) {
stack.push_back(remain++);
answer.push_back('+');
answer.push_back('\n');
}
if (!stack.empty() && stack.back() == current) {
stack.pop_back();
answer.push_back('-');
answer.push_back('\n');
} else {
answer.clear();
answer.push_back('N');
answer.push_back('O');
answer.push_back('\n');
break;
}
}
// make c string
answer.push_back(0);
cout << answer.data();
return 0;
}