結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 254 ms
77,576 KB
testcase_01 WA -
testcase_02 AC 238 ms
77,476 KB
testcase_03 AC 248 ms
77,368 KB
testcase_04 AC 235 ms
77,580 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 92 ms
75,492 KB
testcase_11 AC 90 ms
75,836 KB
testcase_12 AC 85 ms
75,844 KB
testcase_13 AC 85 ms
75,572 KB
testcase_14 AC 85 ms
75,588 KB
testcase_15 AC 100 ms
76,044 KB
testcase_16 AC 101 ms
76,492 KB
testcase_17 AC 100 ms
75,916 KB
testcase_18 AC 102 ms
76,140 KB
testcase_19 AC 106 ms
76,380 KB
testcase_20 AC 93 ms
100,244 KB
testcase_21 AC 94 ms
100,772 KB
testcase_22 AC 75 ms
91,216 KB
testcase_23 AC 112 ms
104,000 KB
testcase_24 AC 101 ms
104,248 KB
testcase_25 AC 76 ms
95,796 KB
testcase_26 AC 70 ms
84,904 KB
testcase_27 AC 99 ms
102,032 KB
testcase_28 AC 93 ms
104,328 KB
testcase_29 AC 81 ms
97,800 KB
testcase_30 AC 92 ms
106,232 KB
testcase_31 AC 101 ms
107,132 KB
testcase_32 AC 103 ms
107,080 KB
testcase_33 AC 99 ms
106,044 KB
testcase_34 AC 107 ms
101,744 KB
testcase_35 AC 96 ms
106,696 KB
testcase_36 AC 96 ms
105,560 KB
testcase_37 AC 99 ms
106,608 KB
testcase_38 AC 95 ms
106,060 KB
testcase_39 AC 97 ms
106,636 KB
testcase_40 AC 114 ms
103,736 KB
testcase_41 AC 110 ms
103,736 KB
testcase_42 AC 118 ms
103,884 KB
testcase_43 AC 113 ms
104,224 KB
testcase_44 AC 116 ms
103,844 KB
testcase_45 AC 111 ms
103,744 KB
testcase_46 AC 116 ms
103,972 KB
testcase_47 AC 115 ms
103,592 KB
testcase_48 AC 116 ms
103,856 KB
testcase_49 AC 115 ms
103,864 KB
testcase_50 AC 120 ms
104,220 KB
testcase_51 AC 116 ms
103,608 KB
testcase_52 AC 116 ms
103,844 KB
testcase_53 AC 113 ms
103,876 KB
testcase_54 AC 118 ms
104,080 KB
testcase_55 AC 117 ms
103,736 KB
testcase_56 AC 120 ms
104,000 KB
testcase_57 AC 121 ms
104,004 KB
testcase_58 AC 120 ms
103,864 KB
testcase_59 AC 120 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

    H = [h // x for h in H]
    tot = [0] * k
    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)) != 1:
        print("No")
        return
    if aft and len(set(aft)) != 1:
        print("No")
        return

    if bef and aft:
        b = bef[0]
        a = aft[0]
        d = a - b
        if d < 0:
            print("No")
            return

        goal = ma + d
        R = [goal - h for h in H]
        minus = [0] * n
        tot = 0
        for i in range(n):
            tot -= minus[i]
            r = R[i] - tot
            if r < 0:
                print("No")
                return
            tot += r
            if i + k < n:
                minus[i + k] = r

    print("Yes")


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