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 bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop,heapify
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

from itertools import accumulate
from functools import lru_cache

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]



n, k = li()
l = li()

dp = [False] * (k + 1)

for i in l:
    for j in range(k + 1):
        if not dp[j - i] and j <= i:dp[j] = True

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

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop,heapify
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

from itertools import accumulate
from functools import lru_cache

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]



n, k = li()
l = li()

dp = [False] * (k + 1)

for i in l:
    for j in range(k - i + 1):
        if not dp[j]:dp[j + i] = True

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

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop,heapify
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

from itertools import accumulate
from functools import lru_cache

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]



n, k = li()
l = li()

dp = [False] * (k + 1)

for i in l:
    for j in range(k - i + 1):
        dp[j + i] |= not dp[j]

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

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop,heapify
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

from itertools import accumulate
from functools import lru_cache

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]



n, k = li()
l = li()

dp = [0] * (k + 1)

for i in l:
    for j in range(k - i + 1):
        dp[j + i] |= 1 - dp[j]
# print(dp)
print('First' if dp[-1] else 'Second')

Submission status: Wrong Answer

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

dp = [0 for i in range(k+1)]
for i in range(len(dp)):
    for j in arr:
        if j+i < k+1:
            dp[j+i] = (dp[i]+1)%2

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
A=list(map(int,input().split()))

dp=[0]*(K+1)

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
A=list(map(int,input().split()))

dp=[0]*(K+1)

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

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

Submission status: Wrong Answer

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

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


if dp[K]==1:
	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 for _ in range(K+1)]
dp[0] = 0
for k in range(1,K+1):
	for a in A:
		if k-a>=0:
			if dp[k-a]==0:
				dp[k]=1


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,K = IL()
A = IL()
a = A[0]

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

for i in range(a,K+1):
  temp = [0]
  for a in A:
    if i >= a:
      temp.append(dp[i-a])
  if not max(temp):
    dp[i] = 1
      
if dp[-1]:
  print("First")
else:
  print("Second")

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,K = IL()
A = IL()
a = A[0]

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

for i in range(a,K+1):
  for a in A:
    temp = [0]
    if i >= a:
      temp.append(dp[i-a])
    if not max(temp):
      dp[i] = 1
      
if dp[-1]:
  print("First")
else:
  print("Second")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 01/08/2020

from sys import stdin, stdout, setrecursionlimit
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007

n, k = iia()
arr = iia()
dp = [False for i in range(k + 1)]
for i in range(1, n + 1):
    for j in range(k + 1):
        if j >= arr[i - 1] and not dp[j - arr[i - 1]]:
            dp[j] = True
if dp[-1]:
    print('First')
else:
    print('Second')

Submission status: Wrong Answer

Solution code:
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 01/08/2020

from sys import stdin, stdout, setrecursionlimit
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007

n, k = iia()
arr = iia()
dp = [[False for i in range(k + 1)] for j in range(n + 1)]
for i in range(1, n + 1):
    for j in range(k + 1):
        if arr[i - 1] > j:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = dp[i - 1][j] or not dp[i][j - arr[i - 1]]
if dp[-1][-1]:
    print('First')
else:
    print('Second')

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
grundy=[0]*(K+1)
for j in range(K+1):
    s=set()
    for i in range(N):
        if a[i]<=j:
            s.add(grundy[j-a[i]])
    g=0
    s=list(s)
    if s!=[]:
        while g<len(s) and g==s[g]:
            g+=1
    grundy[j]=g
if grundy[K]:print("First")
else:print("Second")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)

n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
dp = [-1]*100001
dp[100000] = 0

def mex(l):
    l=list(set(l))
    d={}
    for i in l:
        d[i] = 1
    x=len(l)
    for i in range(0,len(l)):
        try :
            d[i] = d[i] + 1
        except:
            x=i
            break
        return x

def grundy(a,k):
    h = min(a)
    if k<h:
        return 0
    if k==h:
        return 1

    if dp[k]!=-1:
        return dp[k]
    
    dp[k] = mex([grundy(a,k-i) for i in a if k-i>=0])
    return dp[k]

if grundy(a,k) == 0:
    print("Second")
else:
    print("First")

Submission status: Wrong Answer

Solution code:
import sys
def main():
    N,K=tuple(map(int,sys.stdin.readline().split()))
    a=tuple(map(int,sys.stdin.readline().split()))
    dp=[False for _ in range(K+1)]
    for i in range(K+1):
        for x in a:
            if i-x>=0:dp[i]=not dp[i-x]
    print('First') if dp[K] is True else 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 = [0 for k in range(K+1)]

for k in range(K+1):
  if k < min(a):
    dp[k] = -1
  
  if k in a:
    dp[k] = 1
  else:
    for a_ in a:
      if k -a_ >= 1:
        dp[k] = dp[k-a_]*(-1)      
        
if dp[-1] == 1:
  print('First')
else:
  print('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+1):
    flag = 0
    for j in a:
        if i-j < 0:
            continue
        if not dp[i-j]:
            flag = 1
            break

    if flag:
        dp[i] = True

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

print(dp)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
arr=[int(i) for i in input().split()]
dp=[[0 for i in range(k+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(1,k+1):
        if arr[i-1]<=j:
            temp=0
            if dp[i][j-arr[i-1]]==0:
                temp=1
            dp[i][j]=max(temp,dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
if dp[n][k]==1:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
arr=[int(i) for i in input().split()]
dp=[[0 for i in range(k+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(1,k+1):
        if arr[i-1]<=j:
            dp[i][j]=max(1^dp[i][j-arr[i-1]],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
if dp[n][k]==1:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
arr=[int(i) for i in input().split()]
dp=[[0 for i in range(k+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(1,k+1):
        if arr[i-1]<=j:
            dp[i][j]=max(1^dp[i][j-arr[i-1]],dp[i-1][j])
        else:
            dp[i][j]=0
if dp[n][k]==1:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
arr=[int(i) for i in input().split()]
arr.sort()
dp=[[0 for i in range(k+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(1,k+1):
        if arr[i-1]<=j:
            dp[i][j]=1^dp[i][j-arr[i-1]]
if dp[n][k]==1:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
arr=[int(i) for i in input().split()]
arr.sort()
dp=[[0 for i in range(k+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(1,k+1):
        if arr[i-1]<=j:
            dp[i][j]=max(1^dp[i][j-arr[i-1]],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
if dp[n][k]==1:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(int(3e7))

n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[1]*(k+1)
dn=[0]*(k+1)
dp[0]=0
dn[0]=1
def c(i):
    if dn[i]:
        return dp[i]
    else:
        if i-a[0]<0:
            dp[i]=0
        else:
            for j in range(n):
                dp[i] = dp[i] and c(i-a[j])
            dp[i]=(dp[i]+1)%2
        dn[i]=1
        return dp[i]
for l in range(k+1):
    c(k)

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(int(3e7))

n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[1]*(k+1)
dn=[0]*(k+1)
dp[0]=0
dn[0]=1
def c(i):
    if dn[i]:
        return dp[i]
    else:
        if i-a[0]<0:
            dp[i]=0
        else:
            for j in range(n):
                dp[i] = dp[i] and c(i-a[j])
            dp[i]=(dp[i]+1)%2
        dn[i]=1
        return dp[i]
c(k)
print("First" if dp[k] else "Second")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(int(1e7))

n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[1]*(k+1)
dn=[0]*(k+1)
dp[0]=0
dn[0]=1
def c(i):
    if dn[i]:
        return dp[i]
    else:
        if i-a[0]<0:
            dp[i]=0
        else:
            for j in range(n):
                dp[i] = dp[i] and c(i-a[j])
            dp[i]=(dp[i]+1)%2
        dn[i]=1
        return dp[i]
c(k)

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(int(1e7))

n,k=map(int,input().split())
a=list(map(int,input().split()))
m=min(a)
M=max(a)
def c(i,j):
    if 0<=j-M<m:
        return i%2
    elif j-m<0:
        return (i+1)%2
    else:
        return c(i+1,j-m)
d=c(0,k)
print("Second" if d else "First")

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
arr = list(map(int, input().split()))
dp = [False]*(K+1)
for i in range(N):
    for k in range(1,K+1):
        if k - arr[i] >= 0:
            if not dp[k-arr[i]]:
                dp[k] = True
print('First' if dp[K] else 'Second')

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
arr = list(map(int, input().split()))
dp = [False]*(K+1)
for i in range(N):
    for k in range(K+1):
        if k - arr[i] >= 0:
            if not dp[k-arr[i]]:
                dp[k] = True
print('First' if dp[K] else 'Second')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
from functools import lru_cache
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

lst=[0]*(k+1)
# for i in range(a[0]):
#     lst[i]=0
# print(lst)
for i in range(a[0],a[-1]+1):
    lst[i]=1
# print(lst)

for i in range(a[-1]+1,k+1):
    flag=1
    for j in range(n):
        # print(i,a[j])
        flag=min(flag,lst[i-a[j]])

    if flag==0:
        lst[i]=1
    else:
        lst[i]=0
# print(lst)
if lst[k]==1:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
dp = [False]*(2*K + 1)
for i in range(K):
    if not dp[i]:
        for a in A:
            dp[i+a] = True
    print(i,dp)
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 = [1] * (k + 1)
player = ["Second", "First"]

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

print(player[dp[k]])

Submission status: Wrong Answer

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

dp = [1] * k
player = ["Second", "First"]

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

print(player[dp[k - 1]])

Submission status: Wrong Answer

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

c = max(a) + min(a)
k %= c

if k in a:
    print("First")
else:
    print("Second")

Submission status: Wrong Answer

Solution code:
from sys import stdin,stdout
n,k=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
dp=[[-1,-1] for i in range(k+1)]
for i in range(1,k+1):
    for j in a:
        if i>=j:
            if dp[i-j][0]==-1 and dp[i-j][1]==-1:
                dp[i][0]=1
            if dp[i-j][0]==1:
                dp[i][1]=1 
            if dp[i-j][1]==1:
                dp[i][0]=1
if dp[k][0]==1:
    print('First')
else:
    print('Second')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def dfs(x,t):
    if (x,t) in memo:
        return memo[(x,t)]
    if x==0:
        return t^1
    if t==0:
        res=0
        for i in a:
            if i>x:
                break
            if dfs(x-i,t^1):
                res=1
    if t==1:
        res=1
        for i in a:
            if i>x:
                break
            if dfs(x-i,t^1):
                res=0
    memo[(x,t)]=res
    return res

n,k=map(int,input().split())
a=list(map(int,input().split()))
memo={}
print('First' if dfs(k,0) else 'Second')

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
dp = ['emp' for _ in range(K)]
i = 0
while i < min(a):
  dp[i] = 'Second'
  i += 1
for i in range(min(a) - 1, K):
  for j in range(N):
    if dp[i] == 'emp':
      if dp[i-a[j]] == 'Second':
        dp[i] = 'Second'
      else:
        dp[i] = 'First'


print(dp[K-1])

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
                break
    return "First" if dp[-1] else "Second"
print(solve())