結果

問題 No.2860 Heal Slimes
ユーザー rin204
提出日時 2024-08-25 16:14:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,075 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 82,264 KB
実行使用メモリ 107,096 KB
最終ジャッジ日時 2024-08-25 16:14:26
合計ジャッジ時間 10,816 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 54 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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
        minus = [0] * n
        tot = 0
        for i, h in enumerate(H):
            tot -= minus[i]
            h += tot
            if h > goal:
                print("No")
                return
            if i + k >= n + 1 and goal - h > 0:
                print("No")
                return
            tot += goal - h
            if i + k < n:
                minus[i + k] = goal - h

    print("Yes")


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