194642025-12-09 19:43:54birozsSípálya (55 pont)pypy3Time limit exceeded 18/55462ms64000 KiB
N,K=map(int,input().split())
T = list(map(int,input().split()))
def novel(H):
    fold = 0
    poz = H[-1]+len(H)-1
    kilog = []
    for m in H:
        kilog.append(m-poz)
        poz -= 1
    eltolas = max(kilog)
    for k in kilog:
        fold += eltolas - k
    return fold

minhord = N*10**9
for i in range(len(T)-K):
    aktnovel = novel(T[i:i+K])
    if aktnovel < minhord:
        minhord = aktnovel
print(minhord)

    

SubtaskSumTestVerdictTimeMemory
base18/55
1Accepted0/046ms23768 KiB
2Accepted0/050ms22480 KiB
3Accepted2/263ms25476 KiB
4Accepted2/265ms24376 KiB
5Accepted2/264ms21596 KiB
6Accepted2/256ms21572 KiB
7Accepted3/361ms21732 KiB
8Accepted1/1105ms22748 KiB
9Accepted1/1162ms22756 KiB
10Accepted1/1143ms23404 KiB
11Accepted1/1168ms24796 KiB
12Accepted1/1165ms24296 KiB
13Time limit exceeded0/1421ms39908 KiB
14Time limit exceeded0/2462ms45288 KiB
15Accepted2/2166ms24808 KiB
16Runtime error0/2317ms64000 KiB
17Runtime error0/2115ms64000 KiB
18Runtime error0/2115ms64000 KiB
19Runtime error0/3116ms64000 KiB
20Runtime error0/2307ms64000 KiB
21Runtime error0/2287ms64000 KiB
22Runtime error0/2238ms64000 KiB
23Runtime error0/2277ms64000 KiB
24Runtime error0/2232ms64000 KiB
25Runtime error0/2324ms64000 KiB
26Runtime error0/2331ms64000 KiB
27Runtime error0/2240ms64000 KiB
28Runtime error0/3246ms64000 KiB
29Runtime error0/3239ms64000 KiB
30Runtime error0/3282ms64000 KiB