import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import static java.util.Collections.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int N = Integer.parseInt(br.readLine());
int[] target = new int[N];
for (int i = 0 ; i < N; i++)
{
target[i] = Integer.parseInt(br.readLine());
}
Stack<Integer> stack = new Stack<>();
int current = 1;
for (int i = 0 ; i < N; i++)
{
int t = target[i];
while(current <= t)
{
stack.push(current);
sb.append("+\n");
current++;
}
if (stack.peek() == t)
{
stack.pop();
sb.append("-\n");
}
else{
System.out.println("NO");
return;
}
}
System.out.println(sb);
}
}
문제를 이해하는 것 자체가 어려웠고 푸는건 지피티를 이용하여 풀었다. 나는 맨처음에 stack모든 값을 넣고서 시작했는데 이건 맨 처음에 값을 배열에 넣은 후에 stack을 이용하여 push,pop을 사용하였다. 그게 인상깊었다. 확실히 뭔가 어렵다. 코드를 보면 이해는 하겠는데 내가 이걸 과연 다시 할 수 있을까란 의문이 있다. 특히 stack.peek() == t를 이용하여 pop을 사용한게 인상깊었다. 그리고 이걸 통해 peek()와 t가 같지 않으면 NO를 출력하는 것도 너무 깔끔해서 신기했다. 이번 문제는 여러 차례 다시 보아야할 것 같다.