結果

問題 No.1208 anti primenumber game
ユーザー ああいいああいい
提出日時 2022-06-12 16:01:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 123,380 KB
最終ジャッジ日時 2023-10-24 11:46:01
合計ジャッジ時間 8,441 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,400 KB
testcase_01 AC 36 ms
53,400 KB
testcase_02 AC 36 ms
53,400 KB
testcase_03 AC 37 ms
53,400 KB
testcase_04 AC 36 ms
53,400 KB
testcase_05 AC 36 ms
53,400 KB
testcase_06 AC 36 ms
53,400 KB
testcase_07 AC 36 ms
53,400 KB
testcase_08 AC 36 ms
53,400 KB
testcase_09 AC 36 ms
53,400 KB
testcase_10 AC 36 ms
53,400 KB
testcase_11 AC 36 ms
53,400 KB
testcase_12 AC 37 ms
53,400 KB
testcase_13 AC 36 ms
53,400 KB
testcase_14 AC 36 ms
53,400 KB
testcase_15 AC 97 ms
110,644 KB
testcase_16 AC 95 ms
110,644 KB
testcase_17 AC 95 ms
110,644 KB
testcase_18 AC 96 ms
110,644 KB
testcase_19 AC 97 ms
110,644 KB
testcase_20 AC 95 ms
110,644 KB
testcase_21 AC 103 ms
110,708 KB
testcase_22 AC 107 ms
110,708 KB
testcase_23 AC 103 ms
110,644 KB
testcase_24 AC 142 ms
123,368 KB
testcase_25 AC 142 ms
123,380 KB
testcase_26 AC 143 ms
120,772 KB
testcase_27 AC 143 ms
120,780 KB
testcase_28 AC 142 ms
120,776 KB
testcase_29 AC 142 ms
120,772 KB
testcase_30 AC 97 ms
110,644 KB
testcase_31 AC 98 ms
110,644 KB
testcase_32 AC 100 ms
110,644 KB
testcase_33 AC 126 ms
110,644 KB
testcase_34 AC 96 ms
110,644 KB
testcase_35 AC 97 ms
110,644 KB
testcase_36 AC 91 ms
105,716 KB
testcase_37 AC 97 ms
110,644 KB
testcase_38 AC 135 ms
108,688 KB
testcase_39 AC 136 ms
108,676 KB
testcase_40 AC 143 ms
120,808 KB
testcase_41 AC 100 ms
110,412 KB
testcase_42 AC 129 ms
110,400 KB
testcase_43 AC 128 ms
110,400 KB
testcase_44 AC 128 ms
110,400 KB
testcase_45 AC 129 ms
110,400 KB
testcase_46 AC 101 ms
107,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
A = list(map(int,input().split()))

inf = 10 ** 20
dp = [[-inf] * 2 for _ in range(N)]
if A[-1] > 1:
    dp[-1][0] = max(A[-1] - 1 - 1 + M,A[-1] - M)
    dp[-1][1] = -dp[-1][0]
else:
    dp[-1][0] = 1 - M
    dp[-1][1] = M - 1
for i in range(N - 2,-1,-1):
    if A[i] > 1:
        dp[i][0] = max(A[i] - 1 - 1 + M + dp[i + 1][0],A[i] - M + dp[i + 1][1])
        dp[i][1] = -dp[i][0]
    else:
        dp[i][0] = A[i] - M + dp[i + 1][1]
        dp[i][1] = M - 1 + dp[i + 1][0]
print('First' if dp[0][0] > 0 else "Second")
0