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:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, a: "List[int]"):

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

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

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, a)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
dp = [0 for _ in range(k + 1)]
for i in range(1, k + 1):
    for j in a:
        if i >= j:
            if dp[i - j] == 0:
                dp[i] = 1
        if dp[i] == 1:
            break
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 = [0] * (k + 1)

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

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[False]*(k+1)
# dp[i]:残り石i個で自分のターンになった時、勝てるならTrue
# dp[0]=False,dp[a]=True,求めるのはdp[k]
# dp[i]={dp[i-a]の中にひとつでもFalseがあればTrue、other->False}
# <=> すべてのai(in a)についてdp[i]=False->dp[i+ai]=True
for i in range(k+1):
      for ai in a:
            if i+ai<=k and not dp[i]:
                  dp[i+ai]=True
print('First' if dp[k] else 'Second')

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
#n,k=100,100000
#a=range(1,101)

dp=[False for _ in range(k+1)]
calted=[False for _ in range(k+1)]
# dp[i]:残り石i個で自分のターンになった時、勝てるならTrue
# dp[0]=False,dp[a]=True,求めるのはdp[k]
mi=min(a)
ma=max(a)
for ai in a:
	dp[ai]=True
	calted[ai]=True
# dp[i]={dp[i-a]の中にFalseがあればTrue、すべてTrueならFalse}
for i in range(mi+1,k+1):
      if calted[i]:
            continue
      il=[i-ai for ai in a if i-ai>=0]
      f=1
      for l in il:
        f*=dp[l]
      if f == 0:
            dp[i]=True
      else:
            dp[i]=False
print('First' if dp[k] else 'Second')
#print(dp)
#print(datetime.datetime.now())

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
*A, = map(int, input().split())
DP = [False] * (k+1)
for i in range(k+1):
    for a in A:
        if i+a <= k and not DP[i]:
            DP[i+a] = True
if DP[k]:
    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 range(n):
        if i-A[j] < 0:
            continue
        dp[i] |= not dp[i-A[j]]
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] * (10 ** 5 + 10)
for i in range(1, K+1):
    # dp[i-a]の中でどこか一つでもFalseになるdp[i]があればTrueを設定する
    # dp[i-a]がFalseということは、次の手番の相手を負かす取り方が存在するということになるので、この手番でa個取って相手の順番に回してしまえば勝ちが確定する
    # お互いが交互に数字を言っていって、最後に30を言ったほうの負け（最大+3）まで
    # みたいなゲームと同じ構造だと考えていい。上記のゲームで勝つには最後の数から逆算していけば、勝てる数字がわかるのと似ている
    dp[i] = not all(dp[i-a] if i-a >= 0 else True for a in A)

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] * (10 ** 5 + 10)
for i in range(1, K+1):
    dp[i] = not all(dp[i-a] if i-a >= 0 else True for a in A)

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

Submission status: Accepted

Solution code:
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = lambda: sys.stdin.readline().rstrip()

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

#dp[i][j]は残りi個でjが勝つかどうか（j=0 or 1）
dp = [[-1, -1] for _ in range(K+1)]
dp[0] = [0, 0]

for i in range(1, K+1):
    for j in range(2):
        if dp[i][j] > -1:
            continue

        flag = 1
        for x in a:
            if i >= x:
                flag *= dp[i-x][1-j]
        if flag == 0:
            dp[i][j] = 1
        else:
            dp[i][j] = 0
            
print("First" if dp[K][0] else "Second")

Submission status: Accepted

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

for i in range(0,k+1):
    if dp[i] == 0:
        for x in a:
            dp[min(i+x,k+1)] =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()))
ans=[False]*(k+1)
ans[0]=False

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

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

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
ans=[-1]*(k+1)
ans[0]=False # lose

for i in range(k+1):
    iswin = False
    for num in a:
        if (i-num >=0) and (not ans[i-num]):
            iswin=True
    ans[i]=iswin

if ans[-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 for i in range(0,2)] for i in range(0,K+1)]

dp[0][0]='Second'
dp[0][1]='First'

for i in range(1,K+1):
    ans='Second'
    for j in A:
        if i>=j and dp[i-j][1]=='First':
            ans='First'
    dp[i][0]=ans

    ans='First'
    for j in A:
        if i>=j and dp[i-j][0]=='Second':
            ans='Second'
    dp[i][1]=ans

print(dp[K][0])

Submission status: Accepted

Solution code:
# ヒント　dp[i]=(石の個数がi個の時直後の手番の人が勝てるか？)
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 range(n):
        if i-a[j]>=0 and dp[i-a[j]]==0:
            dp[i]=1
# 1つでもi-a[j]==0なら勝てる.
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 stones in range(k+1):
    for x in arr:
        if stones >= x and dp[stones-x] == False:
            dp[stones] = True

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

Submission status: Accepted

Solution code:
def main():
    inp = lambda: [int(x) for x in input().split()]    
    n, k = inp()
    a = inp()
    min_a = min(a)
    dp = [False] * (k+1)
    for i in range(k + 1):
        if i < min_a:
            dp[i] = False
        elif i in a:
            dp[i] = True
        else:
            for j in a:
                if i >= j and not dp[i-j]:
                    dp[i] = True
                    break

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def solve(k, a):
    dp = [False]*(k+1)
    for i in range(1, k+1):
        for x in a:
            if i - x >= 0:
                dp[i] = dp[i] or not dp[i-x]
    return dp[-1]

n, k = map(int, input().split())
a = list(map(int, input().split()))
print('First' if solve(k, a) else 'Second')

Submission status: Accepted

Solution code:
# n=int(input())
n,k=list(map(int,input().split(" ")))
a=list(map(int,input().split(" ")))
mat=[]
a=list(set(a))
res=["L"]*(k+1)
z=min(a)
for i in range(1,k+1):
	if(i in a):
		# print("lol",i)
		res[i]="W"
	else:
		flag=False
		for j in range(len(a)):
			# print(i,k-a[j],res[k-a[j]])
			# print(a)
			if((i-a[j])>=0 and res[i-a[j]]=="L" and i>=z):
				# print(i,k-a[j])
				flag=True
				break
		if(flag==True):
			# print(i,"lllllllllll")
			res[i]="W"
# print(res)
if(res[k]=="W"):
	print("First")
else:
	print("Second")

Submission status: Accepted

Solution code:
def canWinNim(n: int, stones: list):
    states = [False] * (n+1)
    for i in range(1, n+1):
        for step in stones:
            if not states[i-step] and i-step >= 0:
                states[i] = True
    return 'First' if states[-1] else 'Second'

N, K = tuple(map(int, input().split()))
stones = list(map(int, input().split()))
print(canWinNim(K, stones))

Submission status: Accepted

Solution code:
n,k = [int(x) for x in input().split()]

arr  = [int(x) for x in input().split()]

# dp[i] -> having i stones in pile, True if player A can win starting from here

dp = [False]*(k+1)

dp[0] = False


for i in range(1,k+1):
    for e in arr:
        if i - e < 0:
            dp[i] = False
            break
        if dp[i-e] == False:
            dp[i] = True
            break

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

Submission status: Accepted

Solution code:
n,k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

dp = [False]*(k+1)


for i,x in enumerate(dp):
    if not x:        
        for ai in a:
            if i+ai <= k:dp[i+ai] = True
    

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

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
dp = [False] * (k + 1)
for i in range(1, k + 1):
    ok = False
    for j in a:
        if i - j >= 0:
            ok = ok or (not dp[i - j])
    dp[i] = ok

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()))
dp = [[-1,0] for i in range(K+1)]
for i in range(K+1):
    for j in range(N):
        if i+a[j]<=K:
            if dp[i+a[j]][1] == 0:
                dp[i+a[j]][0] = dp[i][0]*(-1)
                dp[i+a[j]][1] = 1
            else:
                if dp[i][0] == -1:
                    dp[i+a[j]][0] = 1 
if dp[K][0] == 1:
    print('First')
else:
    print('Second')

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
#dp[i]:=i個の山の時に、直後のプレイヤーの勝ち負け判定（１：勝　０：負）

dp=[-1]*(K+1)
dp[0]=0

for i in range(1,K+1):
    if all(dp[i-a[j]] if i-a[j]>=0 else 1 for j in range(N)):#直後のプレイヤーが取った後の手が全て勝ちパターンなら、負け確定
        dp[i]=0
    else:
        dp[i]=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()))
# 先手目線で考える。手元にj枚あって、勝てるならTrue
dp = [False]*(k+1)
for i in range(1,k+1):
    flag = False
    for j in range(n):
        if i-A[j] >= 0:
            if dp[i-A[j]] == False:
                flag = True
                break
    if flag:
        dp[i] = True
    else:
        dp[i] = False
if dp[k]:
    print('First')
else:
    print('Second')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    a = list(map(int,input().split()))
    
    dp = [False for _ in range(M+1)]

    for i in range(M+1):
        for num in a:
            if i-num<0:
                continue
            if dp[i-num] == False:
                dp[i] = True

    if dp[M]:
        print("First")
    else:
        print("Second")
   
if __name__ == "__main__":
    main()

Submission status: Accepted

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

dp = [-1]*(k+1)
dp[0] = 0
# 残りの石が i 個のときに手番が勝つ:1 else:0

for i in range(1,k+1):
    j = 0
    while j < n and a[j] <= i:
        if dp[i-a[j]] == 0:
            dp[i] = 1
            break
        j += 1
    if dp[i] == -1:
        dp[i] = 0
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 = [False] * (K+1)

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

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)

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

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N, K = MAP()
a = LIST()

dp = [0]*(K+1)

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

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
A = 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 - A[j] >= 0 and dp[i-A[j]] == 0:
            dp[i] = 1
if dp[k]:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
dp = [0] * (K + 1)
for i in range(K):
  for x in a:
    if i + x <= K:
      if dp[i] == 0: dp[i + x] = 1
if dp[-1]: print("First")
else: print("Second")

Submission status: Accepted

Solution code:
import sys
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:
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:
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=map(int, input().split())
A=list(map(int,input().split()))
dp=[0]*(K+1)
for i in range(K+1):
  for j in A:
    if (i>=j) and (dp[i-j]==0):
      dp[i]=1
if dp[K]:
  print('First')
else:
  print('Second')

Submission status: Accepted

Solution code:
def main():
    N, K, *A = map(int, open(0).read().split())
    dp = [0] * (K + 1)
    for i in range(K):
        if dp[i]:
            continue
        for a in A:
            if i + a > K:
                break
            dp[i + a] = 1
    print("First" if dp[-1] else "Second")
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    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 i-j < 0:
                continue
            if dp[i-j] == 0:
                dp[i] = 1
                break
    if dp[K]:
        print('First')
    else:
        print('Second')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

# dp[i]: 残りがi個の状態で先手が勝つかどうか
dp = [0 for _ in range(K+1)]

# dp[i] = 0: 残りi個で先手が負ける
# dp[i] = 1: 残りi個で先手が勝つ
# dp[i] = -1: 残りi個でも不明
  
for i in range(K + 1):
    # 遷移先: i-aで、そのとき手番は後手
    # どのi-aも1 = 後手がかならず勝つ = 負け
    # 1つでも0がある = 1つでも勝ち筋がある = (その手を打てば)勝ち
    # どのi-aにも遷移できない = 打てない = 負け
    for a in A:
        # 遷移先が存在し、かつそれが勝ち筋
        if i - a >= 0 and not dp[i - a]:
            dp[i] = 1
            break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()

  # 負け：0 勝ち：1
  dp=[0]*(k+1)
  for i in range(k+1):
    for x in l:
      y=i+x

      if y<=k:
        if dp[y]==0:
          dp[y]=abs(dp[i]-1)
  # print(dp)

  if dp[k]==1:
    return 'First'
  return 'Second'

# main()
print(main())

Submission status: Accepted

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

Submission status: Accepted

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

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

dp = [''] * (k + 1)

for i in range(a[0]):
    dp[i] = 'Second'

for x in a:
    dp[x] = 'First'

for i in range(1, k + 1):
    if dp[i] != '':
        continue

    dp[i] = 'Second'
    for x in a:
        if x > i:
            continue
        if dp[i-x] == 'Second':
            dp[i] = 'First'
            break

print(dp[-1])

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):
    for step in a:
        if i - step >= 0:
            dp[i] |= not dp[i-step]
if dp[K]:
    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):
  flg = 0
  for j in a:
    if i-j>=0:
      flg |= 1-dp[i-j]
  dp[i] = flg
if dp[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):
    #初期化
    judge = False
    #選択できる石を選ぶ
    for stone in a:
        #小さい石から選ぶのでこの時点で負け
        if i - stone < 0:
            break
        #ひとつでも勝てるパターンが見つかり次第break
        if dp[i-stone] == False:
            judge = True
            break
    dp[i] = judge
            
print('First' if dp[K] else 'Second')

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
dp = [-1 for k in range(K+1)]
dp[0] = 1
def fn(n):
	if dp[n] != -1:
		return dp[n]
	for i in L:
		if n >= i:
			if fn(n-i) == 1:
				dp[n] = 0
				return 0
	dp[n] = 1
	return 1
for l in range(1, 	K):
	fn(l)
if fn(K) == 0:
	print("First")
else:
	print("Second")

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
dp = [-1 for k in range(K+1)]
dp[0] = 1
def fn(n):
	if dp[n] != -1:
		return dp[n]
	for i in L:
		if n >= i:
			if fn(n-i) == 1:
				dp[n] = 0
				return 0
	dp[n] = 1
	return 1
for l in range(1, 	K):
	fn(l)
if fn(K) == 0:
	print("First")
else:
	print("Second")

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
dp = [-1 for k in range(K+1)]
# dp[0] = 1
def fn(n):
	if dp[n] != -1:
		return dp[n]
	if n == 0:
		dp[n] = 0
		return dp[n]
	ans = 0
	for i in L:
		if n >= i:
			if fn(n-i) == 0:
				ans = 1
				break
	dp[n] = ans		
	return dp[n]
for l in range(K):
	fn(l)
if fn(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[i] := when i stones are remaining can the player win?
dp = [False] * (K+1)
for i in range(1, K+1):
    for j in range(N):
        if i - A[j] >= 0 and not dp[i - A[j]]:
            dp[i] = True
            break
if dp[K]:
    print('First')
else:
    print('Second')

Submission status: Accepted

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

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

for i in range(1, k+1):
  for j in stones:
    if i >= j and dp[i-j] == False:
      dp[i] = True
      continue
      
if dp[k]:
  print("First")
else:
  print("Second")

Submission status: Accepted

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

"""
dp[i]: 残りの石の個数がiの局面で手番が回ってきたときに勝つか負けるか。(boolean)
"""
dp = [False] * (K + 1)

for i in range(K+1):
    for a in A:
        if i - a >= 0:
            if not dp[i - a]:
                dp[i] = True
                continue
if dp[K]:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:

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

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

gr = [0] * (K+1)

for i in range(K+1):

    mex = [0] * (N+1)
    for j in a:
        if i-j >= 0:
            mex[gr[i-j]] = 1

    for k in range(N+1):
        if mex[k] == 0:
            gr[i] = k
            break

if gr[-1] == 0:
    print ("Second")
else:
    print ("First")

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
#dp[i] := 残りi個になったときに先手が勝つかどうか？
dp = [False for i in range(k+1)]
for i in range(n):
    dp[a[i]] = True
#結局dp[k]がTrueなのかFalseなのかを知りたい
for i in range(k+1):
    if dp[i] == False:
        for j in range(n):
            if i + a[j] <= k:
                dp[i+a[j]] = True
if dp[k]:
    print("First")
else:
    print("Second")

Submission status: Accepted

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

dp = [[None] * (k + 1) for _ in range(2)]
# def dfs(at=k, taro=True):
#     if dp[taro][at]:
#         return dp[taro][at]
#
#     if at == 0:
#         r = True ^ taro # taro lose -> False
#         dp[taro][at] = r
#         return r
#
#     results = []
#     for i in range(n):
#         if at >= a[i]:
#             results.append(dfs(at - a[i], not taro))
#
#     if not results:
#         r = True ^ taro
#         dp[taro][at] = r
#         return r
#     r = (any if taro else all)(results)
#     dp[taro][at] = r
#     return r

for at in range(k + 1):
    for taro in range(2):
        if at == 0:
            dp[taro][at] = not taro
            continue
        results = []
        for i in range(n):
            if at >= a[i]:
                results.append(dp[not taro][at - a[i]])

        if not results:
            dp[taro][at] = not taro
            continue
        dp[taro][at] = (any if taro else all)(results)
print('First' if dp[True][k] else '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(N):
    dp[a[i]]=True

for k in range(K+1):
    for n in range(N):
        if k>=a[n]:
            dp[k]=not dp[k-a[n]]
        if dp[k] is True:
            break

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

Submission status: Accepted

Solution code:
# K - Stones
def main():
    N, K, *A = map(int, open(0).read().split())
    dp = [False] * (K + 1)  # dp[i] := a player can win if i stones remain in their turn. (dp[0] := lose)
    for i in range(K):
        if dp[i]:
            continue
        for a in A:
            if i + a > K:
                break
            dp[i + a] = True
            if dp[-1]:
                print("First")
                return
    print("Second")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# K - Stones
def main():
    N, K, *A = map(int, open(0).read().split())
    dp = [False] * (K + 1)
    for i in range(K):
        if dp[i]:
            continue
        for a in A:
            if i + a > K:
                break
            dp[i + a] = True
    print("First" if dp[-1] else "Second")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# K - Stones
def main():
    N, K, *A = map(int, open(0).read().split())
    dp = [0] * (K + 1)
    for i in range(1, K + 1):
        for a in A:
            if i - a >= 0:
                dp[i] |= dp[i - a] ^ 1
            if dp[i]:
                break
    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()))

dp = [False] * (K + 1)
for i in range(1, K + 1):
    # print (dp)
    for a in A:
        if i - a < 0:
            break
        if dp[i - a] == False:
            dp[i] = True
            break

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

Submission status: Accepted

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

# dp
dp = ["W"] * (K + 1)

for i in range(K):
  if dp[K - i] == "W":
    for j in range(N):
      if K - i - a[j] < 0:
        continue
      dp[K - i - a[j]] = "L"

if dp[0] == "W":
  print("Second")
else:
  print("First")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k=map(int,input().split())
A=list(map(int,input().split()))
dp = [False]*(k+1)
for left in range(k+1):
  for i, ai in enumerate(A):
    if left - ai >= 0:dp[left] |= not dp[left-ai]
print("First"if dp[k] else "Second")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k=map(int,input().split())
A=list(map(int,input().split()))
mina = min(A)
dp = [0]*(k+1)
for left in range(k+1):
  win = False
  for i, ai in enumerate(A):
    if left - ai >= 0 and dp[left-ai] == 0:
      win = True
    dp[left] = (1 if win else 0)
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)]
dp[0] = False
for i in range(1, K+1):
    for a in A:
        if i - a >= 0:
            if not dp[i-a]:
                dp[i] = True
                break
if dp[K]:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
arr.sort()
mem = [False for i in range(K+1)]
mem[0] = False
for i in range(K):
  local_result = mem[i]
  for j in arr:
    if i+j <= K:
      mem[i+j] =  mem[i+j] or not local_result
mem[0] = True
#print(mem)
if mem[K]:
  print("First") 
else:
  print("Second")