結果

問題 No.1208 anti primenumber game
ユーザー lam6er
提出日時 2025-04-16 15:36:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 918 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 81,944 KB
実行使用メモリ 119,100 KB
最終ジャッジ日時 2025-04-16 15:41:50
合計ジャッジ時間 5,763 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    M = int(input[idx])
    idx += 1
    A = list(map(int, input[idx:idx+N]))
    
    dp_first = 0
    dp_second = 0
    
    for a in reversed(A):
        if a == 1:
            new_dp_first = (1 - M) + dp_second
            new_dp_second = -(1 - M) + dp_first
        else:
            option1_first = (a - M) + dp_second
            option2_first = (a - 2 + M) + dp_first
            new_dp_first = max(option1_first, option2_first)
            
            option1_second = -(a - M) + dp_first
            option2_second = -(a - 2 + M) + dp_second
            new_dp_second = max(option1_second, option2_second)
        
        dp_first, dp_second = new_dp_first, new_dp_second
    
    if dp_first > 0:
        print("First")
    else:
        print("Second")

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