Submission #3222851


Source Code Expand

Copy
# coding:utf-8


INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = INF
for k in range(1, N + 1):
    e = 5
    cur = N - k
    tmp = e * (B[N] - B[cur]) + (N + k) * X
    cur -= k
    while True:
        tmp += e * (B[cur + k] - B[max(cur, 0)])
        if cur <= 0:
            break
        e += 2
        cur -= k

    ans = min(ans, tmp)

print(ans)

Submission Info

Submission Time
Task B - Garbage Collector
User uni745e
Language Python3 (3.4.3)
Score 700
Code Size 484 Byte
Status
Exec Time 1982 ms
Memory 26020 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Subtask1 400 / 400 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, stest_01.txt, stest_02.txt, stest_03.txt, stest_04.txt, stest_05.txt, stest_06.txt, stest_07.txt, stest_08.txt, stest_09.txt, stest_10.txt, stest_11.txt, stest_12.txt
All 300 / 300 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, stest_01.txt, stest_02.txt, stest_03.txt, stest_04.txt, stest_05.txt, stest_06.txt, stest_07.txt, stest_08.txt, stest_09.txt, stest_10.txt, stest_11.txt, stest_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt
Case Name Status Exec Time Memory
sample_01.txt 16 ms 3064 KB
sample_02.txt 17 ms 3064 KB
sample_03.txt 17 ms 3064 KB
sample_04.txt 17 ms 3064 KB
stest_01.txt 29 ms 3188 KB
stest_02.txt 29 ms 3188 KB
stest_03.txt 17 ms 3064 KB
stest_04.txt 18 ms 3064 KB
stest_05.txt 26 ms 3188 KB
stest_06.txt 24 ms 3064 KB
stest_07.txt 29 ms 3188 KB
stest_08.txt 28 ms 3188 KB
stest_09.txt 21 ms 3064 KB
stest_10.txt 30 ms 3188 KB
stest_11.txt 29 ms 3188 KB
stest_12.txt 18 ms 3064 KB
test_13.txt 1978 ms 25204 KB
test_14.txt 1970 ms 25200 KB
test_15.txt 339 ms 7392 KB
test_16.txt 1922 ms 25348 KB
test_17.txt 1796 ms 24744 KB
test_18.txt 269 ms 6220 KB
test_19.txt 1938 ms 24136 KB
test_20.txt 1943 ms 24252 KB
test_21.txt 1872 ms 24136 KB
test_22.txt 1957 ms 24136 KB
test_23.txt 1833 ms 24744 KB
test_24.txt 1803 ms 24744 KB
test_25.txt 888 ms 14436 KB
test_26.txt 1977 ms 24252 KB
test_27.txt 1982 ms 26020 KB
test_28.txt 1507 ms 20448 KB