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]) :

        save.append(numbers[index])

        index+=1

        # print(save,"두번째구절")

        ans.append("+")

    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(_)


직장인 비전공자 백준밀고 있는데 2시간동안 똥꼬쑈해서 겨우 답만듬 그런데  

 예제입력이랑 다른 입력에서도 정상작동하는데 계속 오답으로뜨는데 반례가있음>?