Submission #13726020


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 << 60

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 665 ms
Memory 645520 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 5
AC × 40
WA × 1
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 72 ms 10636 KB
1.txt AC 62 ms 10172 KB
10.txt AC 37 ms 9432 KB
11.txt AC 80 ms 10792 KB
12.txt AC 40 ms 9608 KB
13.txt AC 71 ms 10548 KB
14.txt AC 99 ms 11116 KB
15.txt AC 129 ms 18944 KB
16.txt AC 123 ms 19116 KB
17.txt AC 128 ms 19112 KB
18.txt AC 130 ms 19256 KB
19.txt AC 129 ms 19252 KB
2.txt AC 46 ms 9668 KB
20.txt AC 127 ms 19112 KB
21.txt AC 131 ms 18940 KB
22.txt AC 120 ms 18216 KB
23.txt AC 248 ms 221656 KB
24.txt AC 430 ms 376904 KB
25.txt AC 158 ms 130084 KB
26.txt AC 30 ms 14828 KB
27.txt AC 149 ms 121636 KB
28.txt AC 665 ms 645520 KB
29.txt AC 575 ms 554260 KB
3.txt AC 22 ms 9280 KB
30.txt AC 23 ms 9044 KB
31.txt AC 16 ms 9044 KB
32.txt AC 22 ms 9096 KB
33.txt WA 17 ms 9048 KB
34.txt AC 23 ms 9036 KB
35.txt AC 37 ms 9460 KB
4.txt AC 40 ms 9580 KB
5.txt AC 49 ms 9712 KB
6.txt AC 42 ms 9544 KB
7.txt AC 83 ms 10600 KB
8.txt AC 27 ms 9036 KB
9.txt AC 76 ms 10812 KB
s1.txt AC 21 ms 9092 KB
s2.txt AC 22 ms 9040 KB
s3.txt AC 20 ms 8936 KB
s4.txt AC 17 ms 8928 KB
s5.txt AC 17 ms 9092 KB