Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
KENEW authored Dec 15, 2020
1 parent 2c24097 commit d5bdede
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions 1874_스택_수열.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include<iostream>
#include<stack>

int main() {
char sol[200050];
int solptr(0);
int n, x, max(0);
std::cin >> n;

std::stack<int> s;
while (n--) {
std::cin >> x;
if (x > max) {
for (int i = max + 1; i <= x; i++)
{
s.push(i);
sol[solptr++] = '+';
}
}
else
if (s.top() != x)
{
std::cout << "NO";
return 0;
}
s.pop();
sol[solptr++] = '-';
if (max < x) max = x;
}
for (int i = 0; i < solptr; i++) std::cout << sol[i] << "\n";

return 0;
}

0 comments on commit d5bdede

Please sign in to comment.