88502024-02-01 21:32:25körteSípálya (55 pont)python3Wrong answer 0/55500ms51288 KiB
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))
legnagyobb = H[0]
e = []
sorrend = []

for i in range(N):
    if H[i] > legnagyobb:
        legnagyobb = H[i]
        e.append(i)
        
for i in range(N):
    sorrend.append(legnagyobb + (e[-1] - i))
    sorrend[i] -= H[i]

petak = sum(sorrend[0:K+1])
for i in range(N-K):
    if sum(sorrend[i:K+1]) < petak:
        petak = sum(sorrend[i:K+1])
print(petak)
    
    
    
    
    
SubtaskSumTestVerdictTimeMemory
base0/55
1Accepted0/017ms11132 KiB
2Wrong answer0/017ms11648 KiB
3Wrong answer0/218ms12088 KiB
4Wrong answer0/218ms12240 KiB
5Wrong answer0/218ms12412 KiB
6Wrong answer0/218ms12212 KiB
7Wrong answer0/318ms12160 KiB
8Wrong answer0/132ms14644 KiB
9Wrong answer0/132ms14624 KiB
10Wrong answer0/135ms15092 KiB
11Wrong answer0/141ms14996 KiB
12Wrong answer0/139ms15376 KiB
13Wrong answer0/1134ms15592 KiB
14Wrong answer0/2194ms16060 KiB
15Wrong answer0/241ms16504 KiB
16Time limit exceeded0/2458ms32660 KiB
17Time limit exceeded0/2456ms34252 KiB
18Time limit exceeded0/2451ms33196 KiB
19Time limit exceeded0/3472ms35932 KiB
20Time limit exceeded0/2462ms37016 KiB
21Time limit exceeded0/2479ms36944 KiB
22Time limit exceeded0/2451ms39792 KiB
23Time limit exceeded0/2453ms41180 KiB
24Time limit exceeded0/2476ms41220 KiB
25Time limit exceeded0/2476ms44136 KiB
26Time limit exceeded0/2474ms45572 KiB
27Time limit exceeded0/2500ms47124 KiB
28Time limit exceeded0/3474ms47268 KiB
29Time limit exceeded0/3479ms51288 KiB
30Time limit exceeded0/3439ms51280 KiB