Submission #3079422


Source Code Expand

Copy
from itertools import accumulate

N, K = map(int, input().split())
x = list(map(int, input().split()))
if N != 1:
    nof_negative = len([x_i for x_i in x if x_i < 0])
    x_negative = [0] + x[nof_negative-1::-1]
    if 0 in x:
        nof_positive = N- nof_negative - 1
        x_positive = x[nof_negative:]
    else:
        nof_positive = N - nof_negative
        x_positive = [0] + x[nof_negative:]

    dir_positive = [2*x_positive[i] - x_negative[K-i] for i in range(max(0,K-nof_negative),min(K,nof_positive))]
    dir_positive = [x_positive[K-i] -2* x_negative[i] for i in range(max(0,K-nof_positive),min(K,nof_negative))]
    ans = min(min(dir_negative),min(dir_positive))
else:
    ans = x[0]
print(ans)

Submission Info

Submission Time
Task C - Candles
User myzs_65c
Language Python (3.4.3)
Score 0
Code Size 731 Byte
Status RE
Exec Time 67 ms
Memory 14448 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 1
RE × 3
AC × 1
RE × 11
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt
Case Name Status Exec Time Memory
0_00.txt RE 17 ms 3064 KB
0_01.txt RE 17 ms 3064 KB
0_02.txt AC 17 ms 3064 KB
0_03.txt RE 17 ms 3064 KB
1_00.txt RE 48 ms 14116 KB
1_01.txt RE 67 ms 14112 KB
1_02.txt RE 49 ms 14100 KB
1_03.txt RE 49 ms 14100 KB
1_04.txt RE 49 ms 14000 KB
1_05.txt RE 49 ms 14000 KB
1_06.txt RE 59 ms 14448 KB
1_07.txt RE 60 ms 14356 KB