結果

問題 No.1208 anti primenumber game
ユーザー tktk_snsntktk_snsn
提出日時 2021-02-11 22:30:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 854 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 118,920 KB
最終ジャッジ日時 2023-09-25 12:16:36
合計ジャッジ時間 9,425 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,200 KB
testcase_01 AC 69 ms
71,216 KB
testcase_02 AC 70 ms
71,216 KB
testcase_03 AC 70 ms
71,052 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 71 ms
71,264 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 72 ms
71,040 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 70 ms
71,336 KB
testcase_14 AC 70 ms
71,208 KB
testcase_15 AC 110 ms
104,424 KB
testcase_16 AC 109 ms
104,288 KB
testcase_17 AC 110 ms
104,524 KB
testcase_18 AC 109 ms
104,448 KB
testcase_19 AC 107 ms
104,236 KB
testcase_20 AC 108 ms
104,568 KB
testcase_21 AC 125 ms
118,508 KB
testcase_22 AC 121 ms
118,240 KB
testcase_23 AC 124 ms
114,136 KB
testcase_24 AC 139 ms
116,736 KB
testcase_25 AC 137 ms
116,548 KB
testcase_26 AC 137 ms
116,144 KB
testcase_27 AC 135 ms
115,872 KB
testcase_28 AC 136 ms
116,148 KB
testcase_29 AC 137 ms
115,912 KB
testcase_30 AC 109 ms
104,620 KB
testcase_31 AC 109 ms
104,404 KB
testcase_32 AC 111 ms
104,552 KB
testcase_33 AC 122 ms
116,528 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 106 ms
108,412 KB
testcase_37 AC 117 ms
118,072 KB
testcase_38 AC 144 ms
111,468 KB
testcase_39 AC 142 ms
111,604 KB
testcase_40 AC 144 ms
116,360 KB
testcase_41 AC 116 ms
106,412 KB
testcase_42 AC 125 ms
118,800 KB
testcase_43 AC 126 ms
118,920 KB
testcase_44 AC 124 ms
114,712 KB
testcase_45 AC 122 ms
114,712 KB
testcase_46 AC 115 ms
109,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

"""
A = 1:取るしかない +1-M   手番が相手に
  = x:1残し +x-1         次も自分
    ぜんぶとる +x-M   手番が相手に
1が連続してるとこは圧縮できる
"""

B = []
for a in A:
    if a == 1 and B and B[-1] == 1:
        B.pop()
        continue
    B.append(a)

if not B:
    print("Second")
    exit()


def game(B, i):
    X, Y = 0, 0
    while i < len(B):
        b = B[i]
        if i + 1 < len(B) and B[i + 1] == 1:
            X += b - M
            Y += 1 - M
            i += 2
        else:
            X += b - 1
            Y += 1 - M
            i += 1
    return X, Y


X = 0
Y = 0
if B and B[0] == 1:
    X = 1 - M
    Q, P = game(B, 1)
else:
    P, Q = game(B, 1)
X += P
Y += Q
if X > Y:
    print("First")
else:
    print("Second")
0