-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboj1874.cpp
52 lines (50 loc) · 1.08 KB
/
boj1874.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
52
#include<bits/stdc++.h>
using namespace std;
int main(){
stack<int> s;
vector<char> ans;
int tmp, n, cur=0;
cin >> n;
cin >> tmp;
for(int i=1;i<=tmp;i++){
s.push(i);
cur++;
ans.push_back('+');
}
s.pop();
ans.push_back('-');
for(int i=0;i<n-1;i++){
cin >> tmp;
if(!s.empty()){
if(s.top()>tmp){
cout << "NO";
return 0;
}
else if(s.top()==tmp){
s.pop();
ans.push_back('-');
}
else{
for(int j=cur+1;j<=tmp;j++){
s.push(j);
cur++;
ans.push_back('+');
}
s.pop();
ans.push_back('-');
}
}
else{
for(int j=cur+1;j<=tmp;j++){
s.push(j);
cur++;
ans.push_back('+');
}
s.pop();
ans.push_back('-');
}
}
for(auto i:ans){
cout << i << "\n";
}
}