Submission #72359585


Source Code Expand

# https://atcoder.jp/contests/abc440/tasks/abc440_c


def main():
    n, w = map(int, input().split())
    c: list[int] = [int(x) for x in input().split()]

    # modごとの和
    s_mod: list[int] = [0] * (2 * w)
    for i in range(n):
        m = i % (2 * w)
        s_mod[m] += c[i]

    ans: int = 0
    for i in range(n):
        if i % (2 * w) < w:
            ans += c[i]
    cur: int = ans
    for k in range(1, 2 * w):
        in_mod = 2 * w - k
        out_mod = w - k
        cur = cur - s_mod[out_mod] + s_mod[in_mod]
        if cur < ans:
            ans = cur
    print(ans)


if __name__ == "__main__":
    t = int(input())
    for _ in range(t):
        main()

Submission Info

Submission Time
Task C - Striped Horse
User ktsn_ud
Language Python (PyPy 3.11-v7.3.20)
Score 300
Code Size 710 Byte
Status AC
Exec Time 182 ms
Memory 131872 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 27
Set Name Test Cases
Sample sample_01.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, sample_01.txt
Case Name Status Exec Time Memory
random_01.txt AC 181 ms 109244 KiB
random_02.txt AC 181 ms 109304 KiB
random_03.txt AC 181 ms 109376 KiB
random_04.txt AC 182 ms 109384 KiB
random_05.txt AC 94 ms 108672 KiB
random_06.txt AC 91 ms 124532 KiB
random_07.txt AC 94 ms 108508 KiB
random_08.txt AC 92 ms 125792 KiB
random_09.txt AC 94 ms 108600 KiB
random_10.txt AC 88 ms 127436 KiB
random_11.txt AC 94 ms 108588 KiB
random_12.txt AC 93 ms 130872 KiB
random_13.txt AC 95 ms 108540 KiB
random_14.txt AC 91 ms 125360 KiB
random_15.txt AC 94 ms 108608 KiB
random_16.txt AC 91 ms 123104 KiB
random_17.txt AC 93 ms 108524 KiB
random_18.txt AC 87 ms 126524 KiB
random_19.txt AC 93 ms 108608 KiB
random_20.txt AC 86 ms 125388 KiB
random_21.txt AC 77 ms 100816 KiB
random_22.txt AC 61 ms 89252 KiB
random_23.txt AC 94 ms 131872 KiB
random_24.txt AC 90 ms 129120 KiB
random_25.txt AC 89 ms 127416 KiB
random_26.txt AC 90 ms 129584 KiB
sample_01.txt AC 54 ms 79952 KiB