結果
問題 |
No.511 落ちゲー 〜手作業のぬくもり〜
|
ユーザー |
![]() |
提出日時 | 2025-04-15 23:32:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 115 ms / 4,000 ms |
コード長 | 1,488 bytes |
コンパイル時間 | 383 ms |
コンパイル使用メモリ | 81,696 KB |
実行使用メモリ | 115,940 KB |
最終ジャッジ日時 | 2025-04-15 23:33:49 |
合計ジャッジ時間 | 3,218 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 32 |
ソースコード
import sys from collections import deque def main(): input = sys.stdin.read().split() ptr = 0 n = int(input[ptr]); ptr += 1 w = int(input[ptr]); ptr += 1 h = int(input[ptr]); ptr += 1 intervals = deque() intervals.append((1, w, 0)) a_score = 0 b_score = 0 for step in range(n): a = int(input[ptr]); ptr += 1 b = int(input[ptr]); ptr += 1 x = int(input[ptr]); ptr += 1 L = x R = x + a - 1 player = 'A' if (step % 2 == 0) else 'B' new_intervals = deque() gain = 0 while intervals: s, e, val = intervals.popleft() if e < L or s > R: new_intervals.append((s, e, val)) continue if s < L: new_intervals.append((s, L - 1, val)) inter_s = max(s, L) inter_e = min(e, R) new_val = val + b if new_val >= h: gain += (inter_e - inter_s + 1) else: new_intervals.append((inter_s, inter_e, new_val)) if e > R: new_intervals.append((R + 1, e, val)) intervals = new_intervals if player == 'A': a_score += gain else: b_score += gain if a_score > b_score: print("A") elif a_score < b_score: print("B") else: print("DRAW") if __name__ == '__main__': main()