結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー lam6er
提出日時 2025-03-26 15:57:14
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,367 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 82,296 KB
実行使用メモリ 76,008 KB
最終ジャッジ日時 2025-03-26 15:57:50
合計ジャッジ時間 8,391 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 24 TLE * 1 -- * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    n = int(input[idx]); idx +=1
    w = int(input[idx]); idx +=1
    h = int(input[idx]); idx +=1

    # Initialize heights
    heights = [0] * (w + 2)  # 1-based to w
    a_scores = 0
    b_scores = 0
    game_ended = False

    for move in range(n):
        if game_ended:
            break
        a = int(input[idx]); idx +=1
        b = int(input[idx]); idx +=1
        x = int(input[idx]); idx +=1
        L = x
        R = x + a - 1

        player = 'A' if (move % 2 == 0) else 'B'
        current_score = 0

        A = max(0, h - b)
        B = h - 1

        for j in range(L, R+1):
            prev = heights[j]
            if prev < h:
                new = prev + b
                if new >= h:
                    current_score += 1
            heights[j] += b

        if player == 'A':
            a_scores += current_score
        else:
            b_scores += current_score

        # Check if all columns >= h
        all_high = True
        for j in range(1, w+1):
            if heights[j] < h:
                all_high = False
                break
        if all_high:
            game_ended = True

    if a_scores > b_scores:
        print("A")
    elif b_scores > a_scores:
        print("B")
    else:
        print("DRAW")

if __name__ == '__main__':
    main()
0