Problem:


Score : 100 points

Problem Statement

There is a set A = \{ a_1, a_2, \ldots, a_N \} consisting of N positive integers.
Taro and Jiro will play the following game against each other.

Initially, we have a pile consisting of K stones.
The two players perform the following operation alternately, starting from Taro:

Choose an element x in A, and remove exactly x stones from the pile.

A player loses when he becomes unable to play.
Assuming that both players play optimally, determine the winner.

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq K \leq 10^5

1 \leq a_1 < a_2 < \cdots < a_N \leq K

Input

Input is given from Standard Input in the following format:

N K
a_1 a_2 \ldots a_N

Output

If Taro will win, print First; if Jiro will win, print Second.

Sample Input 1

2 4
2 3

Sample Output 1

First

If Taro removes three stones, Jiro cannot make a move.
Thus, Taro wins.

Sample Input 2

2 5
2 3

Sample Output 2

Second

Whatever Taro does in his operation, Jiro wins, as follows:

If Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.

If Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.

Sample Input 3

2 7
2 3

Sample Output 3

First

Taro should remove two stones. Then, whatever Jiro does in his operation, Taro wins, as follows:

If Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.

If Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.

Sample Input 4

3 20
1 2 3

Sample Output 4

Second

Sample Input 5

3 21
1 2 3

Sample Output 5

First

Sample Input 6

1 100000
1

Sample Output 6

Second



Sample input:
2 4
2 3


Sample output:
First

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,K = map(int,input().split())
A = [int(x) for x in input().split()]

dp = [False] * (K+K+1)
for i in range(K):
    if not dp[i]:
        for a in A:
            dp[i+a] = True

answer = 'First' if dp[K] else 'Second'
print(answer)

Submission status: Accepted

Solution code:
def solve():
    k, a = read()
    result = think(k, a)
    write(result)


def read():
    n, k = read_int(2)
    a = read_int(n)
    return k, a


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(k, a):
    max_n = 100

    # dp[i] = True/False; True means First player win if num of stone is i
    dp = [False] * (k + max_n + 1)

    for i in range(len(dp)):
        for elem in a:
            if i >= elem:
                dp[i] |= not dp[i - elem]

    return dp[k]


def write(result):
    if result:
        print('First')
    else:
        print('Second')


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
dp=[0 for i in range(k+1)]

for i in range(k+1):
    if dp[i]==0:
        for j in a:
            if i+j<=k:
                dp[i+j]=1
if dp[k]==1:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
import sys
 
input = sys.stdin.readline
 
N, K = map(int, input().rstrip("\n").split())
a = [int(i) for i in input().rstrip("\n").split()]

dp = [True for j in range(K+1)]
dp[0] = False

for j in range(K):
    for i in range(N):
        if j+1 - a[i] >= 0:
            dp[j+1] = dp[j+1] and dp[j+1 - a[i]]
    dp[j+1] = not dp[j+1]

if dp[-1]:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
n , k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
path = [0 for _ in range(k+1)]
# print(path)
for i in range(k+1):
    if path[i]==0:
        for v in a:
            if i+v<=k:
                path[i+v]=1
            else:
                break
print('First' if path[k]==1 else 'Second')

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
a = list(map(int, input().split()))
dp = [0]*(K+1)

for i in range(K):
    if dp[i]==0:
        for j in a:
            if i+j<=K:
                dp[i+j] = 1

print("First" if dp[K]==1 else "Second")

Submission status: Accepted

Solution code:
n,k,*a=map(int,open(0).read().split())
dp=[0]*-~k
for i,d in enumerate(dp):
  if d:continue
  for j in a:
    if i+j<=k:
      dp[i+j]=1
print('SFeicrosntd'[dp[k]::2])

Submission status: Accepted

Solution code:
import math
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()
a = IL()

dp = [-1]*200010
for i in a:
  dp[i] = True

for i in range(1,K+1):
  if dp[i] == -1 or dp[i] == False:
    dp[i] = False
    for j in a:
      dp[i+j] = True

if dp[K] == True:
  print("First")
else:
  print("Second")

Submission status: Accepted

Solution code:
N,K = map(int, input().split())

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

dp = [0] * (K+1)

for k in range(0,K+1):
    for i in A:
        if dp[k] == 0 and k-i >= 0 and dp[k-i] == 0:
            dp[k] = 1

            
if dp[k] == 1:
    print('First')
else:
    print('Second')

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
gru = [0]*(k+1)
for i in range(1,k+1):
  for x in a:
    if i-x >= 0 and gru[i-x] == 0:
      gru[i] = 1
      break
t = ["Second","First"]
print(t[gru[k]])

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
import threading
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N, K = LI()
A = LI()

dp = [False]*(K+1)
for a in A:
    dp[a] = True

for i in range(K+1):
    for a in A:
        if (i<a):
            break
        if (not dp[i-a]):
            dp[i] = True
            break

print("First" if dp[K] else "Second")

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,K = inpl()
aa = inpl()
dp = [0]*(K+1) # 0:未巡回 1:先手勝 -1:後手勝

for i in range(aa[0]):
    dp[i] = -1

for i in range(aa[0],K+1):
    for a in aa:
        if i < a: break
        if dp[i-a] == -1:
            dp[i] = 1
            break

    if dp[i] == 0:
        dp[i] = -1

if dp[-1] == -1:
    print('Second')
else:
    print('First')

Submission status: Accepted

Solution code:
N,K=list(map(int,input().strip().split(" ")))
A=list(map(int,input().strip().split(" ")))
dp=[0]*(K+1)
dp[0]=0
for i in range(1,len(dp)):
    
    for j in range(len(A)):
        if i<A[j]:
            break
        
        if dp[i-A[j]]==0:
            dp[i]=1
if dp[-1]==1:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
# @author 

import sys

class KStones:
    def solve(self):
        n, k = [int(_) for _ in input().split()]
        a = [int(_) for _ in input().split()]
        dp = [0] * (k + 1) # can we win with i remaining ?
        for i in range(min(a), k + 1):
            dp[i] = int(any(not dp[i - x] for x in a if x <= i))
        
        print("First" if dp[k] else "Second")

solver = KStones()
input = sys.stdin.readline

solver.solve()

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

dp = [0] * (K+1)
for i in range(K+1):
    for a in A:
        if dp[i] == 0:
            if i+a <= K:
                dp[i+a] = 1

if dp[K] == 1:
    print('First')
else:
    print('Second')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, K = map(int, input().split())
a = list(map(int, input().split()))
#dp[i]...石がi個でゲームを始めたとき、1:'first'の勝ち、2:'second'の勝ち。
dp = [0] * (K + 1)
dp[0] = 2

for i in range(1, K + 1):
	dp[i] = 2
	
	for x in a:
		if i - x >= 0 and dp[i - x] == 2:
			dp[i] = 1

if dp[K] == 1:
	print('First')
else:
	print('Second')

Submission status: Accepted

Solution code:
n,k= map(int,input().split())
a=list(map(int,input().split()))

dp=[0]*(k+1)

for i in range(1,k+1):
    for j in a:
        if(j<=i):
            if(dp[i-j]==0):
                dp[i]=1


if(dp[k]==1):
    print('First')
else:
    print('Second')

Submission status: Accepted

Solution code:
import fileinput


def who_wins(k, move_list):
    arr = [False] * (k + 1)
    for i in range(1, k + 1):
        for move in move_list:
            if move > i:
                continue
            if arr[i - move] is False:
                arr[i] = True
                break
    return arr[-1]


inp = fileinput.FileInput()
k = int(inp.readline().split(" ")[-1])
move_list = [int(m) for m in inp.readline().split(" ")]

if who_wins(k, move_list):
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
# 入力を受け取る
N, K = map(int, input().split())
A = [int(x) for x in input().split()]

# 動的計画法のテーブルを初期化
dp = [None] * (K + 1)

# テーブルの初期値を設定 石が０個時は必ず負ける
dp[0] = False

# 残り石が少ない方からdpテーブルを埋めてゆく
for n in range(1, K + 1):
    # nより小さいAのカードを抽出
    ta = [x for x in A if x <= n]
    
    # n以下のカードがないなら必ず負ける
    if len(ta) == 0:
        dp[n] = False
    else:
        res = True
        for a in ta:
            res = res and dp[n - a]
        dp[n] = not res

print("First" if dp[K] else "Second")

Submission status: Accepted

Solution code:
import numpy as np
N,K = map(int,input().split())
a = list(int(i) for i in input().split())
res = [0]*(K+1)
for i in range(K):
  for k in a:
    if res[i] == 0:
      if i+k > K:
        break
      else:
        res[i+k] =1
if res[-1] == 1:
  print('First')
else:
  print('Second')

Submission status: Accepted

Solution code:
from collections import Counter
N, K = map(int,input().split())
A = list(map(int,input().split()))
dp = [0]*(K+1)

for i in range(K+1):
    d = set(range(N + 1))
    for a in A:
        if i - a < 0:
            continue
        if dp[i - a] in d:
            d.remove(dp[i - a])
    dp[i] = min(list(d))

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**7)

n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()

# 1:先手　-1:後手
memo = [0]*(k+1)
def dp(x):
    if memo[x] != 0:
        return memo[x]
    for i in a:
        if x < i: break
        else:
            if dp(x-i) == -1:
                memo[x] = 1
                return 1
    memo[x] = -1
    return -1

if dp(k)==1:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
arr = list(map(int, input().split()))
dp = [False] * (k + 1)

for i in range(k + 1):
    if not dp[i]:
        for a in arr:
            if i + a > k:
                break
            dp[i + a] = True

print("First" if dp[k] else "Second")

Submission status: Accepted

Solution code:


n, k = map(int, input().split())
arr = list(map(int, input().split()))

dp = [False] * (k + 1)

for i in range(1, k+1):
    for a in arr:
        if i - a >= 0 and not dp[i - a]:
            dp[i] = True

print("First" if dp[k] else "Second")

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
a = list(map(int,input().split()))

dp = [ False ] *(K+1)

dp[0] = False
for i in range(1,K+1):
    for j in range(N):
        if i - a[j] >= 0:
            dp[i] |= not dp[i-a[j]]


if dp[K] == True:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
mini=min(a)
dp=[-1 for i in range(k+1)]

for x in range(k+1):
	if x == 0 or mini > x:
		dp[x]=False
		continue
	dp[x]=False
	for v in a:
		if v>x:
			continue
		dp[x]=dp[x] or not dp[x-v]

if dp[k]:
	print("First")
else:
	print("Second")

Submission status: Accepted

Solution code:
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
mini=min(a)
dp1=[-1 for i in range(k+1)]
dp2=[-1 for i in range(k+1)]
for x in range(k+1):
	if x == 0 or mini > x:
		dp1[x]=False
		dp2[x]=False
		continue
	dp1[x]=False
	dp2[x]=False
	for v in a:
		if v>x:
			continue
		dp1[x]=dp1[x] or not dp2[x-v]
		dp2[x]=dp2[x] or not dp1[x-v]

if dp1[k]:
	print("First")
else:
	print("Second")

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
A = [int(i) for i in input().split()]
dp = ["Second"]+["First"]*k
for i in range(1,k+1):
    win = "Second"
    for a in A:
        if i-a >= 0 and dp[i-a] == "Second":
            win = "First"
    dp[i] = win
print(dp[k])

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
A = [int(i) for i in input().split()]
dp = ["Second"] + ["First"]*k
for i in range(1,k+1):
    win = "Second"
    for j in range(n):
        if i-A[j] >= 0 and dp[i-A[j]] == "Second":
            win = "First"
    dp[i] = win
print(dp[k])

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (k + 1)

for i in range(k + 1):
    if dp[i] == 0:
        for j in a:
            if i + j > k:
                break
            else:
                dp[i + j] = 1

print("First" if dp[k] else "Second")

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))

dp = [False for _ in range(K + 1)]

for i in range(1, K + 1):
    for j in range(N):
        if i >= A[j]:
            dp[i] |= not dp[i - A[j]]

if dp[K]:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

def main():
    import sys
    #raw = ["2 5", "2 3"]
    raw = [sys.stdin.readline(),
           sys.stdin.readline()]
    N, K = map(int, raw[0].split())
    xs = list(map(int, raw[1].split()))

    M = K + 1
    memo = [False] * M

    for i in range(1, M):
        for j in range(N):
            if i >= xs[j]:
                memo[i] |= not memo[i - xs[j]]

    if memo[K]:
        print("First")
    else:
        print("Second")

    #print(" ".join(map(str, memo)))

main()

Submission status: Accepted

Solution code:
import sys
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, K = mi()
a = lmi()
dp = [False] * (K + 1)

for i in range(1, K + 1):
    for j in a:
        if i >= j and not dp[i - j]:
            dp[i] = True

if dp[K]:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
"""
AtCoder Educational DP Contest
https://atcoder.jp/contests/dp/tasks/dp_k

K - Stones
"""
import collections

def solve(xs):
    dp = collections.defaultdict(bool)
    dp[0] = False
    for j in range(1, K + 1):
        dp[j] = any((j >= x) and (not dp[j - x]) for x in xs)
    return dp[K]

N, K = map(int, input().split())
choices = [int(s) for s in input().split()]
assert len(choices) == N
res = solve(choices)
print("First" if res else "Second")

Submission status: Accepted

Solution code:
"""
AtCoder Educational DP Contest
https://atcoder.jp/contests/dp/tasks/dp_k

K - Stones
"""
import collections

def solve(xs):
    dp = collections.defaultdict(bool)
    dp[0] = False

    for j in range(1, K + 1):
        iterable = ((j >= x) and (not dp[j - x]) for x in xs)
        dp[j] = any(iterable)
    return dp[K]

N, K = map(int, input().split())
choices = collections.Counter([float(s) for s in input().split()])
assert len(choices) == N
res = solve(choices)
print("First" if res else "Second")

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a_s = list(map(int, input().split()))
dp = [0] * (k + 1)
for i in range(k + 1):
    if dp[i] == 0:
        for a in a_s:
            ii = i + a
            if ii > k: break
            dp[ii] = 1
print("First") if dp[-1] else print("Second")

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a_s = list(map(int, input().split()))
dp = ["Second"] * (k + 1)
for i in range(k + 1):
    if dp[i] == "Second":
        for a in a_s:
            ii = i + a
            if ii > k:break
            dp[ii] = "First"
print(dp[-1])

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a_s = list(map(int, input().split()))
dp = ["Second"] * (k + 1)
for i in range(k + 1):
    if dp[i] == "Second":
        for a in a_s:
            ii = i + a
            if ii <= k:
                dp[ii] = "First"
print(dp[-1])

Submission status: Accepted

Solution code:
def judge(i):
    for a in a_s:
        di = i - a
        if di < 0:
            return "Second"
        if dp[di] == "Second":
            return "First"
    return "Second"


n, k = map(int, input().split())
a_s = list(map(int, input().split()))
dp = [""] * (k + 1)
dp[0] = "Second"
for i in range(1, k + 1):
    dp[i] = judge(i)
print(dp[-1])

Submission status: Accepted

Solution code:
import sys
# input処理を高速化する
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    lst_a = list(map(int, input().split()))

    # 石の個数が残りi個の局面で勝ちTrue 負け False　
    dp = [False] * (K+1)

    for i in range(1, K+1):
        for j in range(N):
            if i - lst_a[j] >= 0:
                dp[i] |= not(dp[i - lst_a[j]])
    
    if dp[K]:
        print('First')
    else:
        print('Second')

main()

Submission status: Accepted

Solution code:


n,k = list(map(int,input().split()))

arr = list(map(int,input().split()))
dp = [0 for i in range(k+1)]

for i in range(1,k+1):
    for j in range(n):
        if(i>=arr[j] and (dp[i-arr[j]] == 0)):
            dp[i] = 1
            break

if(dp[k] == 1):
    print('First')

else:
    print('Second')

Submission status: Accepted

Solution code:
#!/snap/bin/pypy3

def main():
    N, K = map(int, input().split())
    A = tuple(map(int, input().split()))

    dp = [False for _ in range(K + 1)]

    for i in range(K + 1):
        tmp_result = False
        for a in A:
            if i - a < 0:
                break
            elif not dp[i-a]:
                tmp_result = True
                break
        dp[i] = tmp_result

    print("First" if dp[-1] else "Second")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
x = [False for _ in range(k+1)]
x[0] = False
for i in range(1,k+1):
  if a[0] > i:
    x[i] = False
  else:
    for ai in a:
      if ai <= i:
        if not x[i-ai]:
          x[i] = True
          break
if x[k]:
  print("First")
else:
  print("Second")

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))

dp = [False]*(k+1)
for i in range(1, k+1):
    flag = False
    for ai in a:
        if i-ai >= 0 and  not dp[i-ai]:
            flag = True
            break
    dp[i] = flag

if dp[-1]:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
d=[0]*(k+1)
for i in range(k+1):
    if d[i]==0:
        for j in a:
            if i+j>k:
                break
            else:
                d[i+j]=1
print("First" if d[k]!=0 else"Second")

Submission status: Accepted

Solution code:
import sys 
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline()

N, K = map(int , input().split())
an = [int(a) for a in input().split()]
dp = [None] *(K+1)
for i in range(an[0]):
    dp[i] = 1
for i in range(an[0],K+1):
    for a in an:
        if i-a>=0 and dp[i-a]==1:
            dp[i]=0
            break
    else:
        dp[i]=1
        
if dp[K]==0:
    print("First")
else:
    print("Second")
#print(dp)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

dp = [False] * (K + 1)  # Firstの勝ちの時にTrue
# dp[0] = False
for k in range(1, K + 1):
    for a in A:
        if a <= k and not dp[k - a]:
            dp[k] = True
            break

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))

t = min(a)

dp = [0] * (k+1)

for x in a:
    dp[x] = 1

for i in range(k+1):
    for x in a:
        if i >= x:
            if dp[i] + (dp[i-x] + 1) % 2 > 0:
                dp[i] = 1
            else:
                dp[i] = 0

print("First" if dp[i] == 1 else "Second")

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
A=tuple(map(int,input().split()))
DP=[False]*(k+1)
for i in range(1,k+1):
    DP[i]=any(not DP[i-a] for a in A if i-a>=0)
print('First' if DP[k] else 'Second')

Submission status: Accepted

Solution code:
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N, K = map(int, input().split())
a = list(map(int, input().split()))

dp = [False]*(K+1)

dp[0] = False
for i in range(1, K+1):
    flag = False
    for e in a:
        if e <= i:
            flag = flag or (not dp[i-e])
    dp[i] = flag
if dp[K]:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
input = sys.stdin.readline

def f2(N, A, K):
    dp = [0] * (K + 1)
    for i in range(K + 1):
        if dp[i] == 0:
            # 残りi個で負けなので、ai個足した状況は勝ちになる。
            for x in A:
                if i + x <= K:
                    dp[i + x] = 1
    return(dp[K])

ans = [ "Second", "First" ]
n, k = map(int, input().split()) # 1 <= n <= 100, 1 <= k <= 10^5
a = list(map(int, input().split()))
print(ans[f2(n, a, k)])

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
input = sys.stdin.readline

def f(N, A, K):
    dp = [0] * (K + 1)
    for i in range(K + 1):
        for x in A:
            if i < x:
                break
            if not dp[i - x]:
                dp[i] = 1
                break
    return(dp[K])

ans = [ "Second", "First" ]
n, k = map(int, input().split()) # 1 <= n <= 100, 1 <= k <= 10^5
a = list(map(int, input().split()))
print(ans[f(n, a, k)])

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


#A
def A():
    n,k = LI()
    a = LI()
    dp = [0 for i in range(k+1)]
    f = [0 for i in range(k+1)]
    for i in range(k+1):
        if not f[i]:
            for j in a:
                if i-j >= 0:
                    dp[i] = 1-dp[i-j]
                    if dp[i] == 0:
                        break
            else:
                dp[i] = 1
    print(["First","Second"][dp[k]])
#B
def B():

    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    A()