90352024-02-12 16:38:46körteSípálya (55 pont)python3Time limit exceeded 4/55483ms132140 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]
minimum = sum(e[0])
for i in range(N-K+1):
    if sum(e[i]) < minimum:
        minimum = sum(e[i])
print(minimum)

SubtaskSumTestVerdictTimeMemory
base4/55
1Accepted0/018ms11512 KiB
2Accepted0/018ms11676 KiB
3Accepted2/235ms12964 KiB
4Accepted2/254ms13936 KiB
5Time limit exceeded0/2432ms6964 KiB
6Time limit exceeded0/2483ms7980 KiB
7Time limit exceeded0/3476ms8020 KiB
8Runtime error0/1152ms132140 KiB
9Runtime error0/1140ms131948 KiB
10Runtime error0/1144ms131756 KiB
11Runtime error0/1115ms131796 KiB
12Runtime error0/1115ms131592 KiB
13Runtime error0/1115ms131500 KiB
14Runtime error0/2116ms131492 KiB
15Runtime error0/2114ms131396 KiB
16Runtime error0/2165ms131028 KiB
17Runtime error0/2120ms131248 KiB
18Runtime error0/2134ms131108 KiB
19Runtime error0/3116ms130932 KiB
20Runtime error0/2135ms130684 KiB
21Runtime error0/2119ms130776 KiB
22Runtime error0/2134ms130744 KiB
23Runtime error0/2116ms130424 KiB
24Runtime error0/2135ms130472 KiB
25Runtime error0/2122ms130364 KiB
26Runtime error0/2123ms130516 KiB
27Runtime error0/2128ms130292 KiB
28Runtime error0/3140ms130092 KiB
29Runtime error0/3131ms130196 KiB
30Runtime error0/3150ms130136 KiB