結果

問題 No.1208 anti primenumber game
ユーザー nebukuro09nebukuro09
提出日時 2020-08-30 14:16:04
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 472 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 570 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 56,696 KB
最終ジャッジ日時 2023-08-09 12:20:50
合計ジャッジ時間 15,139 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,788 KB
testcase_01 AC 15 ms
7,736 KB
testcase_02 AC 15 ms
7,804 KB
testcase_03 AC 16 ms
7,920 KB
testcase_04 AC 16 ms
7,800 KB
testcase_05 AC 16 ms
7,820 KB
testcase_06 AC 16 ms
7,756 KB
testcase_07 AC 16 ms
7,908 KB
testcase_08 AC 16 ms
7,736 KB
testcase_09 AC 16 ms
7,844 KB
testcase_10 AC 16 ms
7,752 KB
testcase_11 AC 17 ms
7,780 KB
testcase_12 AC 16 ms
7,932 KB
testcase_13 AC 15 ms
7,756 KB
testcase_14 AC 15 ms
7,756 KB
testcase_15 AC 311 ms
47,128 KB
testcase_16 AC 278 ms
28,244 KB
testcase_17 AC 309 ms
47,020 KB
testcase_18 AC 276 ms
28,232 KB
testcase_19 AC 318 ms
50,160 KB
testcase_20 AC 335 ms
50,144 KB
testcase_21 AC 399 ms
40,960 KB
testcase_22 AC 412 ms
47,324 KB
testcase_23 AC 367 ms
47,148 KB
testcase_24 AC 439 ms
47,156 KB
testcase_25 AC 438 ms
47,172 KB
testcase_26 AC 462 ms
56,628 KB
testcase_27 AC 467 ms
56,696 KB
testcase_28 AC 464 ms
50,376 KB
testcase_29 AC 472 ms
56,672 KB
testcase_30 AC 332 ms
49,772 KB
testcase_31 AC 325 ms
50,180 KB
testcase_32 AC 321 ms
47,136 KB
testcase_33 AC 403 ms
50,028 KB
testcase_34 AC 403 ms
47,292 KB
testcase_35 AC 400 ms
47,260 KB
testcase_36 AC 304 ms
33,820 KB
testcase_37 AC 414 ms
50,352 KB
testcase_38 AC 424 ms
48,840 KB
testcase_39 AC 441 ms
55,460 KB
testcase_40 AC 462 ms
56,412 KB
testcase_41 AC 342 ms
50,840 KB
testcase_42 AC 408 ms
51,480 KB
testcase_43 AC 414 ms
50,988 KB
testcase_44 AC 384 ms
50,848 KB
testcase_45 AC 376 ms
44,604 KB
testcase_46 AC 331 ms
46,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
a = list(map(int, input().split()))

sm = [0 for _ in range(n+1)]
for i in range(n-1, -1, -1):
    sm[i] = sm[i+1] - m + a[i]

dp = [[0, 0] for i in range(n+1)]

for i in range(n-1, -1, -1):
    if a[i] == 1:
        dp[i][0] = dp[i+1][1] + 1 - m
    else:
        dp[i][0] = max(dp[i+1][0] + a[i] - 1, dp[i+1][1] + a[i] - m)
    dp[i][1] = sm[i] - dp[i][0]

print('First' if dp[0][0] > dp[0][1] else 'Second')
0