#include <stdio.h>
//숫자 스택
int stack[100001];
int top=-1;
int idx=0;
//출력
char res[200002];

void push(int num) {
    stack[++top]=num;
    res[idx++]='+';
}

int pop() {
    res[idx++]='-';
    return stack[top--];
}


int main() {
    int n;
    scanf("%d",&n);
    int num=1;
    for(int i=0; i<n; i++) {
        int target;
        scanf("%d",&target);
        while(num<=target) {
            push(num++);
        }

        if(top!=-1 && stack[top]==target) {
            pop();
        } else {
            printf("NO\n");
            return 0;
        }
    }
    for(int i=0; i<idx; i++) {
        printf("%c\n",res[i]);
    }
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: