65332023-12-07 20:23:31KezdőSípálya (55 pont)python3Time limit exceeded 11/55488ms33960 KiB
from sys import stdin

def main():
    N,K = [int(i) for i in input().split()]
    C = [int(i) for i in stdin.readline().split()]
    CC = [0] + [C[i]+i for i in range(N)]
    s = [0]
    for i in range(N):
        s.append(s[i]+CC[i+1])
    mine = 1e10
    for i in range(N-K+1):
        m = s[i+K] - s[i]
        maxy = max(CC[i:i+K])
        e = 0
        for j in range(i,i+K):
            e += maxy-CC[j]
        if e < mine:
            mine = e
    print(mine)    
main()
SubtaskSumTestVerdictTimeMemory
base11/55
1Accepted0/017ms11380 KiB
2Accepted0/017ms11464 KiB
3Accepted2/218ms11856 KiB
4Accepted2/219ms12312 KiB
5Accepted2/232ms12496 KiB
6Accepted2/245ms12644 KiB
7Accepted3/345ms12576 KiB
8Time limit exceeded0/1460ms6096 KiB
9Time limit exceeded0/1451ms6100 KiB
10Time limit exceeded0/1467ms6300 KiB
11Time limit exceeded0/1479ms6472 KiB
12Time limit exceeded0/1470ms6696 KiB
13Time limit exceeded0/1479ms6732 KiB
14Time limit exceeded0/2488ms7036 KiB
15Time limit exceeded0/2470ms6920 KiB
16Time limit exceeded0/2458ms33852 KiB
17Time limit exceeded0/2472ms33620 KiB
18Time limit exceeded0/2476ms33316 KiB
19Time limit exceeded0/3465ms33760 KiB
20Time limit exceeded0/2465ms33780 KiB
21Time limit exceeded0/2465ms32400 KiB
22Time limit exceeded0/2472ms32516 KiB
23Time limit exceeded0/2472ms33860 KiB
24Time limit exceeded0/2465ms32504 KiB
25Time limit exceeded0/2472ms33732 KiB
26Time limit exceeded0/2486ms33960 KiB
27Time limit exceeded0/2469ms32620 KiB
28Time limit exceeded0/3472ms32684 KiB
29Time limit exceeded0/3485ms32676 KiB
30Time limit exceeded0/3469ms33792 KiB