結果
問題 |
No.2860 Heal Slimes
|
ユーザー |
|
提出日時 | 2024-08-25 16:11:21 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 976 bytes |
コンパイル時間 | 240 ms |
コンパイル使用メモリ | 82,428 KB |
実行使用メモリ | 107,044 KB |
最終ジャッジ日時 | 2024-08-25 16:11:32 |
合計ジャッジ時間 | 10,526 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 54 WA * 6 |
ソースコード
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 tot += goal - h if i + k < n: minus[i + k] = goal - h print("Yes") for _ in range(int(input())): solve()