結果

問題 No.1208 anti primenumber game
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-23 16:26:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 86,376 KB
実行使用メモリ 331,960 KB
最終ジャッジ日時 2023-09-06 21:50:02
合計ジャッジ時間 21,797 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,116 KB
testcase_01 AC 70 ms
70,888 KB
testcase_02 AC 71 ms
70,936 KB
testcase_03 AC 70 ms
71,056 KB
testcase_04 AC 71 ms
70,748 KB
testcase_05 AC 71 ms
70,884 KB
testcase_06 AC 71 ms
71,104 KB
testcase_07 AC 70 ms
71,224 KB
testcase_08 AC 70 ms
70,920 KB
testcase_09 AC 70 ms
71,100 KB
testcase_10 AC 71 ms
71,032 KB
testcase_11 AC 70 ms
71,044 KB
testcase_12 AC 70 ms
71,028 KB
testcase_13 AC 70 ms
71,048 KB
testcase_14 AC 70 ms
71,192 KB
testcase_15 AC 554 ms
307,736 KB
testcase_16 AC 538 ms
308,248 KB
testcase_17 AC 544 ms
308,904 KB
testcase_18 AC 538 ms
307,232 KB
testcase_19 AC 548 ms
308,232 KB
testcase_20 AC 563 ms
307,620 KB
testcase_21 AC 871 ms
321,184 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 122 ms
103,680 KB
testcase_25 AC 124 ms
103,392 KB
testcase_26 AC 122 ms
101,896 KB
testcase_27 AC 122 ms
101,856 KB
testcase_28 AC 122 ms
101,852 KB
testcase_29 AC 122 ms
101,968 KB
testcase_30 AC 542 ms
310,112 KB
testcase_31 AC 541 ms
309,144 KB
testcase_32 AC 575 ms
315,476 KB
testcase_33 AC 770 ms
321,404 KB
testcase_34 AC 107 ms
104,220 KB
testcase_35 AC 106 ms
103,904 KB
testcase_36 AC 98 ms
97,548 KB
testcase_37 AC 106 ms
103,880 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 856 ms
321,864 KB
testcase_43 WA -
testcase_44 AC 729 ms
315,680 KB
testcase_45 WA -
testcase_46 AC 665 ms
288,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)
def main1(n,m,a):
  if all(x>1 for x in a):return True
  memo={}
  def dp(a,i):
    # a[i:]以降だけ考えたとき、互いが最適に行動したときの、(順手の獲得点、逆手の獲得点)
    if i==n:return 0,0
    if (a[i],i) in memo:return memo[(a[i],i)]
    if a[i]==1:
      # 石一個取るしかない。
      x,y=dp(a,i+1)
      ret=[y+a[i]-m,x]
    else:
      # 石ai個取る
      x,y=dp(a,i+1)
      ret=[y+a[i]-m,x]
      # 石ai-1個取る
      tmp=a[i]
      a[i]=1
      x,y=dp(a,i+1)
      a[i]=tmp
      if ret[0]<y+a[i]-1:
        ret=[y+a[i]-1,x]
    memo[(a[i],i)]=ret
    return ret
  ret=dp(a,0)
  return ret[0]>ret[1]

if __name__=='__main__':
  n,m=map(int,input().split())
  a=list(map(int,input().split()))
  ret1=main1(n,m,a)
  if ret1:
    print("First")
  else:
    print("Second")
0