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: Wrong Answer

Solution code:
from sys import stdin, stdout


def solve():
    n,k = [int(i) for i in stdin.readline().split()]
    A = [int(i) for i in stdin.readline().split()]
    dp = [False for _ in range(k + 1)]
    for i in range(n):
        for j in range(A[i], k+1):
            if not dp[j-A[i]]: dp[j] = True
    return "First" if dp[-1] else "Second"
print(solve())

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout
 
 
def solve():
    n,k = [int(i) for i in stdin.readline().split()]
    A = [int(i) for i in stdin.readline().split()]
    dp = [False for _ in range(k + 1)]
    for i in range(n):
        for j in range(A[i], k+1):
            if not dp[j-A[i]]: dp[j] = True
    return "First" if dp[-1] else "Second"
print(solve())

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout


def solve():
    n,k = [int(i) for i in stdin.readline().split()]
    A = [int(i) for i in stdin.readline().split()]
    dp = [False for _ in range(k + 1)]
    for i in range(n):
        for j in range(A[i], k+1):
            if not dp[j-A[i]]: dp[j] = True
    return "First" if dp[j] else "Second"
print(solve())

Submission status: Wrong Answer

Solution code:

def main():
    n, k = map(int, input().split())
    a = tuple(map(int, input().split()))

    dp = [1] * (k + 1)
    dp[0] = 0  # 石がi個で手番が回ってきたら勝てる：1、負ける：0

    for i1 in range(1, k + 1):  # i1：手番が回ってきた時点の石の残数。残数１から始めてｋまでみる。
        if i1 < min(a):  # 「石の個数 < aの最小要素」だと取りようがないので負ける。
            dp[i1] = 0
            continue
        if i1 in a:  #  石の残数を０個にできるので勝てる。
            continue
        pattern1 = []
        pattern2 = []
        for i2 in range(n):
            if i1 - a[i2] > 0:
                pattern1.append((i1 - a[i2]) in a) # 石を取った残り個数がaにある＝次の手番で石を0にされる。
                for i3 in range(n):
                    if i1 - a[i2] - a[i3] >= 0:
                        pattern2.append(dp[i1 - a[i2] - a[i3]] == 0)
        if all(pattern1):
            dp[i1] = 0
        if any(pattern2):
            dp[i1] = 0
    first_te = []
    for j1 in range(n):
        first_te.append(dp[k - a[j1]] == 0)
    if any(first_te):
        print('First')
    else:
        print('Second')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    n, k = map(int, input().split())
    a = tuple(map(int, input().split()))

    dp = [1] * (k + 1)

    dp[0] = 0  # 1：自分の勝利、0：自分の敗北。
    for i1 in range(1, k + 1):  # i1：相手にターンが渡った時点の石の残数。残数１から始めてｋまでみる。
        if 0 <= i1 < min(a):  # 相手に渡った時点で「石の個数 < aの最小要素」なら自分の勝利。
            continue
        else:
            for i2 in range(n):  # 「相手側の勝利」が可能か、aの要素ごとに判定。
                if 0 <= i1 - a[i2] < min(a) or dp[i1 - a[i2]] == 0:
                    dp[i1] = 0
                    break
    for j1 in range(n):
        if dp[k - a[j1]] == 1:
            print('First')
            sys.exit()
    print('Second')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
dp = [False]
for i in range(1, N+1):
    dp.append(not all(dp[i-x] for x in A if i >= x))
print "First" if dp[N] else "Second"

Submission status: Wrong Answer

Solution code:
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
dp = [True]
for i in range(1, N+1):
    dp.append(any(dp[i-x] for x in A if i >= x))
print "First" if dp[N] else "Second"

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
#N=int(input())
A=list(map(int,input().split()))
#p=10**9+7
ma=[]
dp=[False]*(K+1)

for i in range(1,K+1):
    if i in A:
        dp[i]=True
    for j in A:
        if i < j:
            continue
        elif not dp[i-j]:
            dp[i] = True

#print(dp)
if dp[K]:
    print("first")
else:
    print("second")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
A = np.array(list(map(int, input().split())))
A.sort()
amin, amax = A[0], A[-1]


def solve():
    dp = np.zeros(K + 1, dtype=bool)
    for i in range(amin, K + 1):
        dp[i] = np.any(~dp.take(i - A))
    return dp[K]


if __name__ == "__main__":
    print("First" if solve() else "Second")

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


n, k, *a = map(int, read().split())
dp = [False] * (k + 1)
for i in range(k + 1):
    for j in range(n):
        if i - a[j] >= 0:
            dp[i] |= dp[i - a[j]]
if dp[k]:
    print('First')
else:
    print('Second')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

dp = [False] * (K + 1)

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

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

# print(dp)

Submission status: Wrong Answer

Solution code:


def submit():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()

    dp = [False for _ in range(k + 1)]
    for e in a:
        for i in range(k + 1):
            if i >= e:
                dp[i] = dp[i] or not dp[i - e]
    
    if dp[k]:
        print("First")
    else:
        print("Second")

submit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 25 18:20:35 2020
"""

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
N, K = map(int,input().split())
A = np.array(list(map(int,input().split())))

dp = np.arange(K + A[-1]+1) >= 0
for i in range(K, -1, -1):
    if np.all(dp[A+i]):
        dp[i] = False
#    print(i, dp[i],A+i,dp[A+i])
#print(dp)

if dp[0]:
    ans = 'Frist'
else:
    ans = 'Second'
print(ans)

Submission status: Wrong Answer

Solution code:
N, K, *A = map(int, open(0).read().split())

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)

N,K = map(int,input().split())
ali = list(map(int,input().split()))
dp = [-1]*(K+1)
#0=lose 1=win
#メモ化再帰

def fight(st):
  if dp[st] != -1:
    return dp[st]
  if st < min(ali):
    dp[st] = 0
    return 0
  a = 1
  for i in range(N):
    a = min(a,fight(st-ali[i]))
    
  dp[st] = 1-a
  return 1-a

if fight(K) == 1:
  print("First")
else:
  print("Second")

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
dp=np.full(k+1,False)
calted=np.full(k+1,False)
# dp[i]:残り石i個で自分のターンになった時、勝てるならTrue
# dp[0]=False,dp[a]=True,求めるのはdp[k]
mi=np.min(a)
ma=np.max(a)
dp[a]=True
calted[a]=True
# dp[i]={dp[i-a]の中にFalseがあればTrue、すべてTrueならFalse}
for i in range(mi+1,k+1):
      if calted[i]:
            continue
      il=np.maximum(i-a,0)
      f=np.prod(dp[il])
      if f == 0:
            dp[i]=True
      else:
            dp[i]=False
print('First' if dp[k] else 'Second')

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
dp=np.full(k+1,False)
# dp[i]:残り石i個で自分のターンになった時、勝てるならTrue
# dp[0]=False,dp[1]=True,求めるのはdp[k]
mi=np.min(a)
ma=np.max(a)
for i in range(mi,ma+1):
      dp[i]=True
# dp[i]={dp[i-a]の中にFalseがあればTrue、すべてTrueならFalse}
for i in range(ma+1,k+1):
      il=i-a
      f=np.prod(dp[il])
      if f == 0:
            dp[i]=True
      else:
            dp[i]=False
print('First' if dp[k] else 'Second')
#print(dp)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

    for i in range(M):
        for num in a:
            dp[i+num] = -1*dp[i]

    if 1 in dp[M-min(a)+1:M+1]:
        print("First")
    else:
        print("Second")
   
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
l=[int(x) for x in input().split()]
l.sort(reverse=True)
a=l[0]
c=0
while(K>=a):
  K=K-a
  c=c+1
if K==0:
  if c%2!=0:
    print("Taro")
  else:
    print("Jiro")
else:
  if K in l:
    c=c+1
    if c%2!=0:
      print("First")
    else:
      print("Second")

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
l=[int(x) for x in input().split()]
l.sort(reverse=True)
a=l[0]
c=0
while(K>=a):
  K=K-a
  c=c+1
if K==0:
  if c%2!=0:
    print("Taro")
  else:
    print("Jiro")
else:
  if K in l:
    c=c+1
    if c%2!=0:
      print("Taro")
    else:
      print("Jiro")

Submission status: Wrong Answer

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

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

dp[0] = -1

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

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

Submission status: Wrong Answer

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

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

dp[0] = -1

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

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

Submission status: Wrong Answer

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

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

dp[0] = -1

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

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

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
def main():
    N,K=map(int,input().split())
    lst_a=list(map(int,input().split()))
    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: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
def main():
    N,K=map(int,input().split())
    lst_a=list(map(int,input().split()))
    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: Wrong Answer

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

print(dp)

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

Submission status: Wrong Answer

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にも遷移できない = 打てない = 負け
    if all([i - a < 0 for a in A]):
        dp[i] = 0
    else:
        if all([dp[i - a] == 1 for a in A]):
            dp[i] = 0
        else:
            dp[i] = 1

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

Submission status: Wrong Answer

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にも遷移できない = 打てない = 負け
    if all([i - a <= 0 for a in A]):
        dp[i] = 0
    else:
        if all([dp[i - a] == 1 for a in A]):
            dp[i] = 0
        else:
            dp[i] = 1

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

Submission status: Wrong Answer

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にも遷移できない = 打てない = 負け
    if all([i - a < 0 for a in A]):
        dp[i] = 0
    else:
        if all([dp[i - a] == 1 for a in A]):
            dp[i] = 0
        else:
            dp[i] = 1

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

Submission status: Wrong Answer

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

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

# dp[i] = 0: 残りi個で先手が負ける

for i in range(K + 1):
    # 遷移先: i-aで、そのとき手番は後手
    # どのi-aも1 = 後手がかならず勝つ = 負け
    # 1つでも0がある = 1つでも勝ち筋がある = (その手を打てば)勝ち
    # どのi-aにも遷移できない = 打てない = 負け
    if all([i - a < 0 for a in A]):
        dp[i] = 0
    else:
        dp[i] = 0 if all([dp[i - a] == 1 for a in A]) else 1

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

Submission status: Wrong Answer

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 < L[0]:
		dp[n] = 1
		return 1
	if n in L:
		dp[n] = 0
		return 0
	for i in L:
		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: Wrong Answer

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
dp = [-1 for k in range(K+1)]
dp[0] = 0
def fn(n):
	if dp[n] != -1:
		return dp[n]
	if n < L[0]:
		dp[n] = 1
		return 1
	if n in L:
		dp[n] = 0
		return 0
	for i in L:
		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: Wrong Answer

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

Submission status: Wrong Answer

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):
        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: Wrong Answer

Solution code:
# K - Stones
from collections import defaultdict


def main():
    N, K, *A = map(int, open(0).read().split())
    dp = defaultdict(bool)  # dp[i] := a player can win if i stones remain in their turn. (dp[0] := lose)
    dp[0] = False
    cnt = 0
    while cnt < K:
        for a in A:
            for i in tuple(dp.keys()):
                if a + i > K:
                    break
                dp[a + i] = True
                cnt += 1
    print("First" if dp[-1] else "Second")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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 + A[0] - 1) // A[0]):
        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: Wrong Answer

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

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

Submission status: Wrong Answer

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] |= dp[left-ai]
print("First"if dp[k] else "Second")

Submission status: Wrong Answer

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
sys.setrecursionlimit(10**7)

n,k = map(int,input().split())
A = list(map(int,input().split()))
mina = min(A)
dp=[[-1]*(k+1) for i in range(2)]

def rec(oddeven,left):
  if dp[oddeven][left] != -1: return dp[oddeven][left]
  if left < mina:return (oddeven+1)%2
  for i,ai in enumerate(A):
    if rec((oddeven+1)%2 , left-ai) == oddeven:
      dp[oddeven][left] = oddeven
      return oddeven
  dp[oddeven][left] = (oddeven+1)%2    
  return (oddeven+1)%2

print("Second" if rec(0,k) else "First")

Submission status: Wrong Answer

Solution code:
def main():
  n,k=map(int,input().split())
  num=[int(i) for i in input().split()]
  
  dp=[0]*(k+1)
  for i in range(k):
    flag=False
    for j in range(n):
      if dp[max(i+1-num[j],0)]==0:
        flag=True
        break
    if flag:
      dp[i+1]=1
    else:
      continue
  if dp[k]:
    print('First')
  else:
    print('Second')          
if __name__=='__main__':
  main()

Submission status: Wrong Answer

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

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

for i in range(1, k+1):
  for j in range(n):
    if i - l[j] >= 0:
      dp[i] = 1 - dp[i-l[j]]
      
if dp[k] == 0:
  print('Second')
else:
  print('First')

Submission status: Wrong Answer

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

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

for i in range(1,k+1):
  for j in range(n):
    if i >= aa[j]:
      dp[i] = max(dp[i],-dp[i-aa[j]])

if dp[k]>0:
  print('first')  
else:
  print('second')

Submission status: Wrong Answer

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

win = [0]*(k+1)
for i in range(min(aa)):
  win[i] = -1

for i in range(1,k+1):
  if i in aa:
    win[i] = 1
  
  for ai in aa:
    if i+ai < k+1:
      win[i+ai] = -win[i]  

if win[k]>0:
  print('first')  
else:
  print('second')

Submission status: Wrong Answer

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

dp = [float("inf") for i in range(k+1)]

for i in range(al[0]):
    dp[i] = 0 

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


if dp[-1] % 2 == 0:
    print("Second")
else:
    print("First")

Submission status: Wrong Answer

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

dp = [float("inf") for i in range(k+1)]

for i in range(al[0]):
    dp[i] = 0 

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

print(dp)
if dp[-1] % 2 == 0:
    print("Second")
else:
    print("First")

Submission status: Wrong Answer

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

dp = [float("inf") for i in range(k+1)]

for i in range(al[0]):
    dp[i] = 0 

for i in range(k):
    for a in al:
        if i+a <= k:
            dp[i+a] = dp[i] + 1


if dp[-1] % 2 == 0:
    print("Second")
else:
    print("First")

Submission status: Wrong Answer

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

dp = [0] * (K+1)

for a in A:
    dp[a] = 1

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000000)

N, K = map(int, raw_input().split())
A = list(map(int, raw_input().split()))

def is_winner(k):
    if k == 0:
        return False

    ans = False
    for x in [3]:
        # print first, " Plays %s" % x
        if k >= x and not is_winner(k - x):
            # print first, " winner for %s" % k
            ans = True

    return ans

print "First" if is_winner(K) else "Second"

Submission status: Wrong Answer

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

dp = [False] * (K+1)

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

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

Submission status: Wrong Answer

Solution code:
def stones(k, moves):
    winnable = [False] * (k + 1)
    for i in range(1, k+1):
        winnable[i] = not all(winnable[i - j] for j in moves if j <= i)
    print([int(x) for x in winnable])
    return ["Second", "First"][winnable[k]]

def main():
    n, k = [int(x) for x in input().split()]
    moves = [int(x) for x in input().split()]
    return stones(k, moves)

print(main())

Submission status: Wrong Answer

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

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

for j in range(K+1):
    q = j // A[0]
    if q%2 == 1:
        dp[0][j] = True
        memo[j] = True
        
for _ in range(2):
    for i in range(1, N):
        for j in range(K+1):
            if j < A[i]:
                dp[i][j] = False
            else:
                if memo[j-A[i]]:
                    dp[i][j] = False
                else:
                    dp[i][j] = True
                    memo[j] = True
                
ans = "Second"
for i in range(N):
    if dp[i][K]:
        ans = "First"
        break
        
print(ans)

Submission status: Wrong Answer

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

dp = [[True]*(K+1) for _ in range(N)]
memo = [True]*(K+1)

for j in range(K+1):
    q = j // A[0]
    if q%2 == 0:
        dp[0][j] = False
        memo[j] = False
        
for i in range(1, N):
    for j in range(K+1):
        if j < A[i]:
            dp[i][j] = False
        else:
            if memo[j-A[i]]:
                dp[i][j] = False
            else:
                dp[i][j] = True
                memo[j] = True
                
ans = "Second"
for i in range(N):
    if dp[i][K]:
        ans = "First"
        break
        
print(ans)

Submission status: Wrong Answer

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


dp = [False] * (K+1)
for ai in a:
    for k in range(K+1):
        if k >= ai:
            dp[k] = dp[k] or (not dp[k-ai])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0,0]  for j in range(K+1)]
dp[0][1]=1
for i in range(1,K+1):
    for j in range(N):
        if i-a[j]>=0:
            dp[i][0]=max(dp[i-a[j]][1],dp[i][0])
            dp[i][1]=(dp[i][0]+1)%2
        
if dp[K][0]:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0,0]  for j in range(K+1)]
dp[0][1]=1
for i in range(1,K+1):
    for j in range(N):
        if i-a[j]>=0:
            dp[i][0]=max(dp[i-a[j]][1],dp[i][0])
            dp[i][1]=max(dp[i-a[j]][0],dp[i][1])
        
if dp[K][0]:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0,0]  for j in range(K+1)]
dp[0][1]=1
for i in range(1,K+1):
    for j in range(N):
        if i-a[j]>=0:
            dp[i][0]=max(dp[i-a[j]][1],dp[i][0])
            dp[i][1]=max(dp[i-a[j]][0],dp[i][1])
if dp[K][0]:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0,0]  for j in range(K+1)]
dp[0][1]=1
for i in range(1,K+1):
    for j in range(N):
        if i-a[j]>=0:
            dp[i][0]=max(dp[i-a[j]][1],dp[i][0])
            dp[i][1]=max(dp[i-a[j]][0],dp[i][1])
print(dp[K][0])

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)


def main():
    N, K = map(int, input().split())
    A = tuple(sorted(map(int, input().split())))
    c = [0] * (K + 1)
    def dp(k, A, c, turn):
        if c[k] != 0:
            return c[k] * turn
        t = -turn
        for i in A:
            if i > k:
                break
            if dp(k - i, A, c, -turn) == turn:
                t = turn
                break
        c[k] = t
        return t
    
    print('First' if dp(K, A, c, 1) == 1 else 'Second')


main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)


def main():
    N, K = map(int, input().split())
    A = tuple(sorted(map(int, input().split())))
    c = [0] * (K + 1)
    def dp(k, A, c, turn):
        if c[k] != 0:
            return c[k] * turn
        t = -turn
        for i in A:
            if i > k:
                break
            if dp(k - i, A, c, -turn) == turn:
                t = turn
                break
        c[k] = t
        return t
    
    print('First' if dp(K, A, c, 1) else 'Second')


main()

Submission status: Wrong Answer

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

def main():
    l = [False] * (K+1)
    for i in range(K+1):
        if i < a[0]:
            l[i] = False
        else:
            l[i] = any(not l[i-j] if i >= j else True for j in a)
    if l[-1]:
        print('First')
    else:
        print('Second')


main()

Submission status: Wrong Answer

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