https://www.acmicpc.net/problem/1874

Baekjoon Online JudgeBaekjoon Online Judgewww.acmicpc.net



n = int(input()) #8
can_u_make=[]
save=[]
result=[]
ans=[]
numbers=[]
index=0
can_index=0
first_cnt=0
x=0

for _ in range(1,n+1):
    numbers.append(_) # [1,2,3,4,5,6,7,8]   # [1,2,3,4,5]
# print("numbers:",numbers)
for i in range(n):
    can_u_make.append(int(input()))
    # [4,3,8,7,5,2,1]   # [5,1,2,5,3,4]
# print("can_u_make:",can_u_make)

while result!=can_u_make:
    if first_cnt==0:    #한번만 실행되는 구절
        save.append(numbers[index])
        first_cnt+=1
        index+=1
        # print(save,"첫구절")
        ans.append("+")
    if (result!=can_u_make) and (len(save)==0):
        print("NO")
        break
    elif (save[-1]!=can_u_make[can_index])and (len(numbers)>index):
        save.append(numbers[index])
        index+=1
        # print(save,"두번째구절",index)
        ans.append("+")
    elif (save[-1]!=can_u_make[can_index]) and (len(numbers)<=index):
        # print("NO","인덱스 초과")
        break
    elif save[-1]==can_u_make[can_index]:
        save.remove(can_u_make[can_index])
        result.append(can_u_make[can_index])
        # print(save,"세번째 구절",can_index)
        ans.append("-")
        # index+=1
        can_index+=1


if len(save)==0 and result==can_u_make:    # 만약 save리스트가 전부 비어져있다면
    for _ in ans:
        print(_)


index가 numbers 크기보다 커지는경우랑 result 랑 can_u_make 같아지기전에  save 가 빈 리스트가되면 NO가 출력되게 했는데 

계속 7%에서 틀렸습니다 뜸 

반례가 있는거임? 

반례는 어떻게 스스로 찾음? 

비전공 머갈통으로 아무리생각해도 모르겠다..