-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1874.cpp
More file actions
59 lines (52 loc) · 1.01 KB
/
Copy path1874.cpp
File metadata and controls
59 lines (52 loc) · 1.01 KB
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
52
53
54
55
56
57
58
59
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
// 스택에서 수를 빼줄 때 top()에 있는 것을 제거해줘야 나중에 pop을 할 때 오류가 안 생김.
// 만약에 4를 입력하고서 2를 입력했다 치면 나중에 3을 pop할 때 오류가 생김
/*int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
stack<int> st;
vector<string> v;
int a, cnt = 0;
int k = 1;
while (cnt < n) {
cin >> a;
if (st.empty() || st.top() < a) {
for (int i = k; i <= a; i++) {
st.push(i);
v.push_back("+");
k++;
}
if (st.empty()) {
cout << "NO";
return 0;
}
st.pop();
v.push_back("-");
}
else {
bool found = false;
if (a == st.top()) {
found = true;
}
for (int j = st.top(); j >= a; j--) {
st.pop();
v.push_back("-");
}
if (!found) {
cout << "NO";
return 0;
}
}
cnt++;
}
for (int i = 0; i < v.size(); i++) {
cout << v[i] << '\n';
}
return 0;
}*/