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
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    """
    N個の足場があります。足場には1,2,…,Nと番号が振られています。 
    各i (1≤i≤N) について、足場 i の高さは hi です。
    最初、足場 1 にカエルがいます。 カエルは次の行動を何回か繰り返し、足場 N まで辿り着こうとしています。
    足場 i にいるとき、足場 i+1 または i+2 へジャンプする。
    このとき、ジャンプ先の足場を j とすると、コスト |hi−hj| を支払う。
    カエルが足場 N に辿り着くまでに支払うコストの総和の最小値を求めてください。

    制約
        入力はすべて整数である。
    2≤N≤10**5
    1≤hi≤10**4
    """
    n = II()
    h = LI()
    dp = [0 for i in range(n)]
    dp[1] = abs(h[0] - h[1])
    for i in range(2,n):
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))
    print(dp[n-1])
    return

#B
def B():
    n, K = LI()
    h = LI()
    dp = [float("INF") for i in range(n + K + 1)]
    dp[0] = 0
    for i in range(n):
        for k in range(1, K + 1):
            if i + k >= n:
                break
            dp[i + k] = min(dp[i + k], dp[i] + abs(h[i] - h[i + k]))
    print(dp[n-1])
    return

#C
def C():
    n = II()
    abc = LIR(n)
    dp = [0 for i in range(3 * n + 1)]
    dp[0] = abc[0][0]
    dp[1] = abc[0][1]
    dp[2] = abc[0][2]
    for i in range(1,n):
        dp[3 * i] = max(dp[3 * i], dp[3 * (i - 1) + 1] + abc[i][0], dp[3 * (i - 1) + 2] + abc[i][0])
        dp[3 * i + 1] = max(dp[3 * i + 1], dp[3 * (i - 1) + 2] + abc[i][1], dp[3 * (i - 1)] + abc[i][1])
        dp[3 * i + 2] = max(dp[3 * i + 2], dp[3 * (i - 1) + 1] + abc[i][2], dp[3 * (i - 1)] + abc[i][2])
    dp[3 * n] = max(dp)
    print(dp[3*n])

    return

#D
def D():
    """N個の品物があります。 品物には 1,2,…,Nと番号が振られています。 
    各 i (1≤i≤N) について、品物i の重さはwi で、価値はvi です。
    太郎君は、N 個の品物のうちいくつかを選び、ナップサックに入れて持ち帰ることにしました。 
    ナップサックの容量は W であり、持ち帰る品物の重さの総和は W以下でなければなりません。
    太郎君が持ち帰る品物の価値の総和の最大値を求めてください
    
    入力はすべて整数である。
    1≤N≤100
    1≤W≤10**5
    1≤wi≤W
    1≤vi≤10**9"""
    n, w = LI()
    wv = LIR(n)
    dp = [[0 for k in range(w + 1)] for i in range(n + 2)]
    for i in range(1,n + 1):
        for j in range(w + 1):
            if j < wv[i-1][0]:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = max(dp[i][j], dp[i][j - wv[i - 1][0]] + wv[i - 1][1])
    print(dp[n+1][w])

    
    return

#E
def E():
    """N個の品物があります。 品物には 1,2,…,Nと番号が振られています。 
    各 i (1≤i≤N) について、品物i の重さはwi で、価値はvi です。
    太郎君は、N 個の品物のうちいくつかを選び、ナップサックに入れて持ち帰ることにしました。 
    ナップサックの容量は W であり、持ち帰る品物の重さの総和は W以下でなければなりません。
    太郎君が持ち帰る品物の価値の総和の最大値を求めてください
    
    入力はすべて整数である。
    1≤N≤100
    1≤W≤10**9
    1≤wi≤W
    1≤vi≤10**3"""
    n, w = LI()
    wv = LIR(n)
    dp = [[float("INF") for i in range(10 ** 5 + 1)] for k in range(n + 1)]
    dp[0][0] = 0
    for i in range(n):
        for k in range(10 ** 5 + 1):
            if k < wv[i][1]:
                dp[i + 1][k] = dp[i][k]
            else:
                dp[i + 1][k] = min(dp[i][k], dp[i][k - wv[i][1]] + wv[i][0])
    ans = 0
    for i in range(10 ** 5 + 1):
        if dp[n][i] <= w:
            ans = i
    print(ans)

    return

#F
def F():
    s = S()
    t = S()
    dp = [[0 for i in range(len(t)+1)] for k in range(len(s)+1)]
    for i in range(len(s)):
        for j in range(len(t)):
            if s[i] == t[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                if dp[i][j + 1] < dp[i + 1][j]:
                    dp[i + 1][j + 1] = dp[i + 1][j]
                else:
                    dp[i + 1][j + 1] = dp[i][j + 1]
    ss = len(s)
    tt = len(t)
    ans = ""
    si = ss
    ti = tt
    while si > 0 and ti > 0:
        if dp[si][ti] == dp[si - 1][ti]:
            si -= 1
        elif dp[si][ti] == dp[si][ti - 1]:
            ti -= 1
        else:
            si -= 1
            ti -= 1
            ans = s[si]+ans


    print(ans)
    return

#G
def G():
    n, m = LI()
    xy = LIR_(m)
    edge = [[] for i in range(n)]
    for x,y in xy:
        edge[x].append(y)
    dp = [0 for i in range(n)]
    def ans(dp, i):
        #print(dp, i)
        if dp[i] != 0:
            return dp[i]
        else:
            if len(edge[i]) == 0:
                return 0
            ansb = 0
            for k in edge[i]:
                #print(dp, k , i)
                ansb = max(ansb, ans(dp, k) + 1)
                dp[i] = max(ansb, dp[i])
                #print(dp)
            return ansb
            
    for i in range(n):
        dp[i] = ans(dp, i)
    print(max(dp))
    return

#H
def H():
    h, w = LI()
    a = SR(h)
    dp = [[0 for i in range(w)] for k in range(h)]
    for i in range(w):
        if a[0][i] == "#":
            break
        dp[0][i] = 1
    for i in range(h):
        if a[i][0] == "#":
            break
        dp[i][0] = 1
    for i in range(1,w):
        for k in range(1, h):
            #print(i,k, dp)
            if a[k - 1][i] == ".":
                if a[k][i - 1] == ".":
                    dp[k][i] = dp[k - 1][i] + dp[k][i - 1] % mod
                else:
                    dp[k][i] = dp[k - 1][i]
            else:
                if a[k][i - 1] == ".":
                    dp[k][i] = dp[k][i - 1]
    print(dp[h-1][w-1] % mod)

    return

#I
def I():
    n = II()
    p = LF()
    dp = [[0 for k in range(n+1)] for i in range(n+1)]
    dp[1][1] = p[0]
    dp[1][0] = 1-p[0]
    for i in range(2,n+1):
        for k in range(i + 1):
            if k == 0:
                
                dp[i][k] = dp[i-1][k] * (1 - p[i-1])
            else:
                dp[i][k] = dp[i - 1][k - 1] * p[i - 1] + dp[i - 1][k] * (1 - p[i - 1])
    #print(dp)
    print(sum(dp[n][n//2+1:]))
    return 
#J
def J():
    n = II()
    a = LI()


#K
def K():
    n, k = LI()
    an = LI()
    dp = [0 for i in range(k + 1)]
    dp[0] = 0
    ans = ["First","Second"]
    for i in range(k + 1):
        if i in an:
            dp[i] = 0
        else:
            for num, a in enumerate(an):
                if a < i:
                    if dp[i - a] == 1:
                        dp[i] = 0
                        break
            else:
                dp[i] = 1
        #print(dp,i)

    print(ans[dp[k]])

#L

#M
#N
# O
# P
# Q
# R
# S
# T
# U
# V
# W
# X
# Y
# Z


#Solve
if __name__ == '__main__':
    K()

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

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
dp=[0]*(k+1)
# for i in range(n+1):
# 	dp[i]=[0]*(k+1)
arr=list(map(int,input().split()))
for i in range(1,k+1):
	for j in range(n):
		if i-arr[j]<0:
			continue
		elif i-arr[j]==0:
			dp[i]=1
		else:
			dp[i]|=not dp[i-arr[j]]
# print(dp)
if dp[i]:
	print("First")
else:
	print("Second")

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
##dp[i][j]:i番目までの元を用いたとき、j個の石の山についてどっちが勝つか
dp = [True]*(k+1)

dp[0] = False


for j in range(1,k+1):
  for i in range(n):
    if j>=a[i]:
      if not dp[j-a[i]]:
        dp[j] = True
        break
    dp[j] = False
if dp[k]:
  print("First")
else:
  print("Second")

Submission status: Accepted

Solution code:
import os
from io import BytesIO

input = BytesIO(os.read(0, os.fstat(0).st_size)).readline

n, k = map(int, input().split())
a = sorted(int(i) for i in input().split())

dp = [False] * (k + 1)

for i in xrange(k + 1):
    for ai in a:
        if ai > i:
            break
        if not dp[i - ai]:
            dp[i] = True
            break

os.write(1, '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) #残りの石iで回ってきたときの勝敗
for i in range(k+1):
    dp[i] = 0
    for j in a:
        if j > i:
            break
        if 1 - dp[i-j]:
            dp[i] = 1
            break
print(['Second', 'First'][dp[k]])

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
S = list(map(int, input().split()))
dp = [0]*(K+1)

for i in range(K+1):
    if dp[i] == 0:
        for s in S:
            if i+s > K:
                continue
            else:
                dp[i+s] = 1
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):
    DP[i] = not all(DP[i-a] for a in A if i - a >= 0)

print('First' if DP[k] else '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):
    DP[i] = not all(DP[i-a] for a in A if i - a >= 0)

print('First' if DP[k] else '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):
    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:
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


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

    # dp[i]: 石がi個の局面で1.勝つか0.負けるか
    dp = [0] * (k + 1)

    for i in range(k + 1):
        if not dp[i]:
            for a in A:
                if i + a > k:
                    continue
                dp[i + a] = 1
        # print(dp)

    return 'First' if dp[k] else 'Second'


print(main())

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(K+1) :
    for a in A :
        if i-a < 0 :
            pass
        elif i-a == 0 :
            dp[i] = "First"
            break
        elif dp[i-a] == "Second" :
            dp[i] = "First"
            break
    else :
        dp[i] = "Second"
ans = dp[K]
print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
t=sorted(map(int,input().split()))
dp=[-float('inf')]*(k+1)
dp[:t[0]]=[0]*t[0]
for i in range(k):
    for j in range(n):
        if i+t[j]<k+1:
            dp[i+t[j]]=max(dp[i+t[j]],(dp[i]+1)%2)
print(['Second','First'][dp[-1]%2])

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

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

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

Submission status: Accepted

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

DP = [0]*(K+1)
for i in range(K, -1, -1):
    if DP[i]%2 == 0:
        for a in A:
            if i - a < 0:
                break
            DP[i-a] = 1
if DP[0]:
    print("First")
else:
    print("Second")

Submission status: Accepted

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

DP = [0]*(K+1)
for i in range(K, -1, -1):
    if DP[i]%2 == 0:
        for a in A:
            if i - a < 0:
                break
            DP[i-a] = 1
if DP[0]:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
a = list(li())

LOSE = -1
WIN = 1

dp = [0]*(k+1)
for i in range(a[0]):
    dp[i] = LOSE
    
for i in range(a[0], k+1):
    lost = True
    for ai in a:
        if i-ai < 0:
            continue
        
        if dp[i-ai] == LOSE:
            lost = False
            
    dp[i] = LOSE if lost else WIN
    
print('First') if dp[k] == WIN 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 a in A:
        if i-a < 0: break
        if not dp[i-a]:
            dp[i] = True
print('First' if dp[-1] else 'Second')

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (k+1)
s = ["Second", "First"]

for i in range(1, k+1):
    for x in a:
        if x <= i:
            if b[i-x] == 0:
                b[i] = 1
                break

print(s[b[k]])

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [None] * (K+1)
    for i in range(K+1):
        dp[i] = False
        for j in range(N):
            if A[j] <= i and dp[i - A[j]] == False:
                dp[i] = True
    if dp[K]:
        print("First")
    else:
        print("Second")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

dp = [False] * (K + 1)

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

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

else:
    print("Second")

Submission status: Accepted

Solution code:
N,K=[int(x) for x in raw_input().split()]
A=[int(x) for x in raw_input().split()]
B=[-1 for i in range(K+1)]
F=[]
n=0
for i in range(A[0]):
    B[i]=0
for i in range(A[0],K+1):
    tmp= [B[i-a] for a in A if i-a>-1]
    if sum(tmp) == len(tmp):
        B[i]=0
    else:
        B[i]=1
print ["Second","First","bug"][B[K]]

Submission status: Accepted

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

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

for i in range(min(a),k+1):
    dp[i]=any(not dp[i-j] for j in a if i>=j)

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

Submission status: Accepted

Solution code:


n, k = map(int, raw_input().split())
a = map(int, raw_input().split())

dp = [False] * (k + 1)
for i in range(1, k + 1):
    for x in a:
        if x <= i:
            if not dp[i - x]:
                dp[i] = True
                break
        else:
            break
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 in range(min(a), k + 1):
  dp[i] = any(not dp[i - j] for j in a if i - j >= 0)
print('First' if dp[k] else 'Second')

Submission status: Accepted

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

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

dp = [False] * (K + 1)

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

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

Submission status: Accepted

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python

import sys
sys.setrecursionlimit(10**9)

N,K = map(int, input().split())
A = list(map(int, input().split()))
A = list(filter(lambda x: x<=K, A))
m = min(A)

# $B%a%b2=:F5"(B
dp = [ -1 for _ in range(K+1)]

for i in range(m):
    dp[i] = 0
for a in A:
    dp[a] = 1

def rec(i):
    global dp
    if dp[i] == -1:
        for a in A:
            if i-a >= 0 and dp[i-a] == -1:
                rec(i-a)
            
        dp[i] = 1 if any(dp[i-x] == 0 for x in A if i-x >= 0) else 0 # ( 0 if all(dp[i-x] == 1 for x in A) else 1)
        return dp[i]
    else:
        return dp[i]

print("First" if rec(K) else "Second")
# print(dp)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

"""
参考：https://kyopro-friends.hatenablog.com/entry/2019/01/12/231000
・ゲームDP
・負け状態を押し付けられるかどうか
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

# メモ[山の残数] = 今の手番が勝てるか
dp = [False] * (K+1)
# 残数0は負け確定
dp[0] = False

for i in range(1, K+1):
    for j in range(N):
        # j枚取った時、負け状態に出来るなら、それを取ればいいので今の手番は勝てる
        if i-aN[j] >= 0 and dp[i-aN[j]] == 0:
            dp[i] = True
            break
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()))
ans = [False]*(k+1)
for i in range(1,k+1):
    ok = False
    for j in a:
        if i-j<0:
            continue
        if ans[i-j] == False:
            ans[i] = True
            break

print('First' if ans[k] else 'Second')

Submission status: Accepted

Solution code:
import sys
N,K=map(int, raw_input().split())
A=map(int, sys.stdin.readline().split())

dp=[ None for i in range(K+1) ]

for i in range( min(A) ):
	dp[i]="L"


for i,x in enumerate(dp):
	if x is None:
		for j in A:
		#	print "i,j,i-j,dp[i-j] :::: ",  i, j,i-j,dp[i-j]
			if 0<=i-j and dp[i-j]=="L":
				dp[i]="W"
				break
		else:
			dp[i]="L"


print "Second" if dp[K]=="L" else "First"

Submission status: Accepted

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

for i in range(1,k+1):
    v=False
    for j in a:
        if j>i:break
        if not res[i-j]:
            v=True
            break
    if v:
        res[i]=True

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
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 LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,k = LI()
    a = LI()
    r = [0] * (k+1)
    for i in range(1,k+1):
        f = False
        for c in a:
            if c > i:
                break
            if r[i-c] == 0:
                f = True
                break
        if f:
            r[i] = 1

    if r[k] == 1:
        return 'First'

    return 'Second'


print(main())

Submission status: Accepted

Solution code:
from sys import setrecursionlimit
setrecursionlimit(100000)

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

dp = [False]*(K+1)

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
X = [0] * (K + 1) # 後手必勝のところが1

X[K] = 1
for i in range(K)[::-1]:
    for a in A:
        if i + a <= K:
            if X[i+a] == 1:
                break
    else:
        X[i] = 1
        
print(["First", "Second"][X[0]])

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
# firstが負けの状態を押し付け続けることが可能ならば勝ち
dp = [False]*(K+1)
# dp[i](0,A[0]) = False 
for i in range(K):
    if not dp[i]:
        for a in A:
            if i+a <= K:
                dp[i+a] = 1
print("First" if dp[K] else "Second")

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
dp=[0]*(K+1)
dp[0]=0
for i in range(1,K+1):
    flag=0
    s=1
    for a in A:
        if i-a>=0:
            s*=dp[i-a]
            flag=1
    if flag==0:
        dp[i]=0
    else:
        dp[i]=1-s
#print(dp)
if dp[K]==0:
    print('Second')
else:
    print('First')

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]: continue
    for a in A:
        if i+a > K: break
        dp[i+a] = 1
print('First' if dp[-1] else 'Second')

Submission status: Accepted

Solution code:
# coding: utf-8
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[None for i in range(k+1)]
dp[0]=False
for i in range(k+1):
    f=False
    for x in a:
        if i-x<0:
            continue
        if dp[i-x]==True:
            dp[i]=False
            break
    else:
        dp[i]=True
print('First' if not dp[-1] else 'Second')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
dp = [None for _ in range(k+1)]
#dp[i]: i個のときにどっちが勝つか
for i in range(a[0]):
	dp[i] = "Second"
dp[a[0]] = "First"
for i in range(a[0]+1, k+1):
	f = False
	for j in range(n):
		if i < a[j]:
			break
		else:
			if dp[i - a[j]] == "Second":
				f = True
				break
	if f:
		dp[i] = "First"
	else:
		dp[i] = "Second"

#print(dp)
print(dp[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
aaa = list(map(int, input().split()))
dp = [False] * (k + 1)
for i in range(1, k + 1):
    win = None
    for a in aaa:
        j = i - a
        if j < 0:
            break
        if dp[j] == False:
            win = True
            break
    if win is None:
        win = False
    dp[i] = win
print('First' if dp[k] else 'Second')

Submission status: Accepted

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

dp = [0]*(K+1)
for c in range(K+1):
    for a in A:
        if a <= c and not dp[c-a]:
            dp[c] = 1
            break
print('First' if dp[K] else 'Second')

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, raw_input().split())
    A = list(map(int, raw_input().split()))
    
    # dp[i] := 残りの石の数がi個の時、勝ちか負けか(先手目線)
    dp = [0] * (K + 1)
    
    for i in range(K + 1):
        for a in A:
            if i - a < 0:
                continue
    
            if dp[i - a] == 0:
                dp[i] = 1
                break
    
    print('First' if dp[-1] else 'Second')
    
main()

Submission status: Accepted

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

DP=[None]*(K+1)
for i in range(A[0]):
    DP[i]=1#Jiro wins.

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

    else:
        DP[i]=1

#print(DP)
            
if DP[K]==0:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
a = list(li())
dp = [-1]*(k+1)
dp[0] = 0

for m in range(1,k+1):
    for ai in a:
        if m - ai >= 0:
            if dp[m-ai] == 0:
                dp[m] = 1
                break
    
        dp[m] = 0
    
print("First") if dp[k] == 1 else print("Second")

Submission status: Runtime Error

Solution code:
n,k=int(input()),int(input())
l=list(map(int,input().split()))
if(k%2==0):
  print("Second")
else:
  print("First")