제출 #527120

#제출 시각아이디문제언어결과실행 시간메모리
527120HoneybeeLabels (NOI20_labels)Cpython 3
25 / 100
797 ms41448 KiB
N = int(input())
user2 = input().split()
lst = []
low = 0
change = 0
valid = False

for i in user2:
    lst.append(int(i))
    if int(i) < 0:
        if abs(int(i)) > change:
            low = abs(int(i)) - change  
    change += int(i)
        

if N == 2:
    if lst[0] == 0:
        print('-1')
    elif lst[0] == 1:
        print('1 2')
    else:
        print('2 1')
else:
    output = [1 + low]
    if output[-1] == N:
        valid = True
    for i in range(len(lst)):
        output.append(lst[i] + output[i])
        
        if output[-1] == N:
            valid = True

        if output[-1] > N:
            valid = False
            break
        
    if valid == False:
        print('-1')
    else:
        for i in output:
            print(i)
            print(' ')
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...