結果

問題 No.2860 Heal Slimes
ユーザー 👑 rin204rin204
提出日時 2024-08-25 16:24:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 965 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 107,384 KB
最終ジャッジ日時 2024-08-25 16:24:31
合計ジャッジ時間 10,458 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 221 ms
77,588 KB
testcase_01 WA -
testcase_02 AC 259 ms
79,420 KB
testcase_03 AC 224 ms
77,412 KB
testcase_04 AC 241 ms
77,392 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 87 ms
75,828 KB
testcase_11 AC 87 ms
75,640 KB
testcase_12 AC 90 ms
75,592 KB
testcase_13 AC 82 ms
75,932 KB
testcase_14 AC 79 ms
75,812 KB
testcase_15 AC 92 ms
76,024 KB
testcase_16 AC 96 ms
75,980 KB
testcase_17 AC 93 ms
75,952 KB
testcase_18 AC 103 ms
76,036 KB
testcase_19 AC 102 ms
76,228 KB
testcase_20 AC 89 ms
100,332 KB
testcase_21 AC 86 ms
100,916 KB
testcase_22 AC 69 ms
91,460 KB
testcase_23 AC 104 ms
103,380 KB
testcase_24 AC 93 ms
104,268 KB
testcase_25 AC 77 ms
96,036 KB
testcase_26 AC 66 ms
84,932 KB
testcase_27 AC 89 ms
101,492 KB
testcase_28 AC 88 ms
104,072 KB
testcase_29 AC 77 ms
97,432 KB
testcase_30 AC 91 ms
106,072 KB
testcase_31 AC 105 ms
107,384 KB
testcase_32 AC 99 ms
107,020 KB
testcase_33 AC 89 ms
106,032 KB
testcase_34 AC 103 ms
101,900 KB
testcase_35 AC 93 ms
106,704 KB
testcase_36 AC 89 ms
105,704 KB
testcase_37 AC 94 ms
106,420 KB
testcase_38 AC 92 ms
106,260 KB
testcase_39 AC 104 ms
106,688 KB
testcase_40 AC 106 ms
103,860 KB
testcase_41 AC 106 ms
103,840 KB
testcase_42 AC 106 ms
103,632 KB
testcase_43 AC 109 ms
104,124 KB
testcase_44 AC 120 ms
103,872 KB
testcase_45 AC 108 ms
103,484 KB
testcase_46 AC 109 ms
103,848 KB
testcase_47 AC 107 ms
103,712 KB
testcase_48 AC 106 ms
103,844 KB
testcase_49 AC 107 ms
103,712 KB
testcase_50 AC 109 ms
103,984 KB
testcase_51 AC 111 ms
103,600 KB
testcase_52 AC 107 ms
103,864 KB
testcase_53 AC 111 ms
103,612 KB
testcase_54 AC 110 ms
104,024 KB
testcase_55 AC 111 ms
104,240 KB
testcase_56 AC 108 ms
104,372 KB
testcase_57 AC 110 ms
103,960 KB
testcase_58 AC 121 ms
103,712 KB
testcase_59 AC 117 ms
103,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n, k, x = map(int, input().split())
    H = list(map(int, input().split()))
    if len(set(h % x for h in H)) != 1:
        print("No")
        return

    tot = [0] * k
    H = [h // x for h in H]
    ma = max(H)

    for i, h in enumerate(H):
        tot[i % k] += ma - h

    bef = tot[: n % k]
    aft = tot[n % k :]
    if bef and len(set(bef)) >= 2:
        print("No")
        return
    if aft and len(set(aft)) >= 2:
        print("No")
        return

    if bef and aft:
        if bef[0] > aft[0]:
            print("No")
            return

        d = aft[0] - bef[0]
        goal = ma + d
        rem = [goal - h for h in H]
        minus = [0] * (n + k)
        x = 0
        for i, r in enumerate(rem):
            x -= minus[i]
            r -= x
            if r < 0:
                print("No")
                return
            minus[i + k] = r
            x += r

    print("Yes")


for _ in range(int(input())):
    solve()
0