Submission #13725677


Source Code Expand

Copy
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

INF = 1 << 30

bound = [0] * (N + 1)
bound[0] = 1
ok = True
for n in range(1, N + 1):
    bound[n] = min(INF, (bound[n - 1] - A[n - 1]) * 2)
    if bound[n] < A[n]:
        ok = False

if not ok:
    print(-1)
    exit()

B = [0] * (N + 2)
for n in range(N, -1, -1):
    x = min(bound[n], B[n + 1] + A[n])
    B[n] = x

print(sum(B))

Submission Info

Submission Time
Task C - Folia
User maspy
Language Python (3.8.2)
Score 0
Code Size 512 Byte
Status WA
Exec Time 680 ms
Memory 645184 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 5
AC × 33
WA × 8
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt, s4.txt, s5.txt
All 0.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 3.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, s1.txt, s2.txt, s3.txt, s4.txt, s5.txt
Case Name Status Exec Time Memory
0.txt AC 74 ms 10820 KB
1.txt AC 65 ms 10000 KB
10.txt AC 38 ms 9320 KB
11.txt AC 86 ms 10604 KB
12.txt AC 42 ms 9440 KB
13.txt AC 69 ms 10228 KB
14.txt AC 99 ms 10940 KB
15.txt WA 125 ms 18088 KB
16.txt WA 122 ms 18076 KB
17.txt WA 132 ms 18392 KB
18.txt WA 131 ms 18264 KB
19.txt WA 128 ms 18272 KB
2.txt AC 49 ms 9968 KB
20.txt WA 126 ms 18264 KB
21.txt WA 127 ms 18076 KB
22.txt AC 135 ms 18208 KB
23.txt AC 255 ms 221476 KB
24.txt AC 410 ms 376836 KB
25.txt AC 160 ms 130060 KB
26.txt AC 30 ms 14768 KB
27.txt AC 157 ms 121740 KB
28.txt AC 680 ms 645184 KB
29.txt AC 580 ms 554492 KB
3.txt AC 22 ms 9128 KB
30.txt AC 18 ms 9104 KB
31.txt AC 17 ms 9196 KB
32.txt AC 20 ms 9164 KB
33.txt WA 18 ms 8940 KB
34.txt AC 24 ms 9024 KB
35.txt AC 39 ms 9516 KB
4.txt AC 45 ms 9456 KB
5.txt AC 53 ms 9708 KB
6.txt AC 41 ms 9596 KB
7.txt AC 81 ms 10720 KB
8.txt AC 26 ms 9048 KB
9.txt AC 77 ms 10680 KB
s1.txt AC 17 ms 9168 KB
s2.txt AC 22 ms 8932 KB
s3.txt AC 17 ms 9096 KB
s4.txt AC 19 ms 8924 KB
s5.txt AC 20 ms 9168 KB