88512024-02-02 12:44:32körteSípálya (55 pont)python3Wrong answer 0/55479ms132172 KiB
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))
e = []
s = []

def legnagyobb(lista):
    lnagyobb = 0
    poz = []
    for i in range(len(lista)):
        if lista[i] > lnagyobb:
            lnagyobb = lista[i]
            poz.append(i)
    return lnagyobb, poz[-1]

for i in range(N-K+1):
    e.append(H[i:K+i])
    s.append(H[i:K+i])
for i in range(N-K+1):
    for j in range(K):
        e[i][j] = (legnagyobb(e[i])[0] + legnagyobb(e[i])[1] - j)

for i in range(N-K+1):
    for j in range(K):
        e[i][j] -= s[i][j]
print(e)
minimum = sum(e[0])
for i in range(N-K+1):
    if sum(e[i]) < minimum:
        minimum = sum(e[i])
print(minimum)

SubtaskSumTestVerdictTimeMemory
base0/55
1Wrong answer0/018ms11360 KiB
2Wrong answer0/017ms11360 KiB
3Wrong answer0/235ms13216 KiB
4Wrong answer0/256ms13680 KiB
5Time limit exceeded0/2449ms6920 KiB
6Time limit exceeded0/2479ms7992 KiB
7Time limit exceeded0/3470ms7836 KiB
8Runtime error0/1177ms132172 KiB
9Runtime error0/1138ms131908 KiB
10Runtime error0/1144ms131540 KiB
11Runtime error0/1115ms131500 KiB
12Runtime error0/1116ms131580 KiB
13Runtime error0/1118ms131456 KiB
14Runtime error0/2116ms131524 KiB
15Runtime error0/2114ms131472 KiB
16Runtime error0/2143ms131484 KiB
17Runtime error0/2115ms131376 KiB
18Runtime error0/2118ms131372 KiB
19Runtime error0/3119ms131056 KiB
20Runtime error0/2136ms131284 KiB
21Runtime error0/2122ms131372 KiB
22Runtime error0/2136ms131108 KiB
23Runtime error0/2118ms131000 KiB
24Runtime error0/2136ms130504 KiB
25Runtime error0/2120ms130548 KiB
26Runtime error0/2140ms130332 KiB
27Runtime error0/2130ms130224 KiB
28Runtime error0/3129ms130300 KiB
29Runtime error0/3133ms130248 KiB
30Runtime error0/3135ms130204 KiB