Problem:


Score : 100 points

Problem Statement

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

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

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

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

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq K \leq 10^5

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

Input

Input is given from Standard Input in the following format:

N K
a_1 a_2 \ldots a_N

Output

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

Sample Input 1

2 4
2 3

Sample Output 1

First

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

Sample Input 2

2 5
2 3

Sample Output 2

Second

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

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

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

Sample Input 3

2 7
2 3

Sample Output 3

First

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

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

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

Sample Input 4

3 20
1 2 3

Sample Output 4

Second

Sample Input 5

3 21
1 2 3

Sample Output 5

First

Sample Input 6

1 100000
1

Sample Output 6

Second



Sample input:
2 4
2 3


Sample output:
First

Submission status: Accepted

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

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

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

def main():
  n,k=LI()
  dp=[0]*100100
  l=LI()

  for i in range(k):
    for x in l:
      if i+x<=k:
        if dp[i+x]==0 and dp[i]==0:
          dp[i+x]=1

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

# main()
print(main())

Submission status: Accepted

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

Submission status: Accepted

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 not dp[i-a]:
      dp[i] = 1
      break
result = dp[k]
if result:
  print("First")
else:
  print("Second")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N,K = MI()
A = LI()
dp = [True]*(K+1)
for i in range(min(A),K+1):
    ret = True
    for a in A:
        if i-a>=0:
            if dp[i-a]==True:
                ret = False
                break
    dp[i] = ret

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

Submission status: Accepted

Solution code:
from sys import stdin, stdout
from collections import deque, defaultdict
import math as m

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, k = rli()
	A = list(rli())
	dp = [0 for _ in range(k + 1)]
	for i in range(1, k + 1):
		for num in A:
			if i - num < 0:
				continue
			if dp[i]: 
				break
			if not dp[i-num]: 
				dp[i] = 1
	print("First" if dp[-1] else "Second")
	stdout.close()

if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    dp=[False]*(k+1) #0:i個だったら必ず負ける，正:勝つ
    for i in range(min(A),k+1):
        for a in A:
            if i-a>=0 and not dp[i-a]:
                dp[i]=True
                break
        else:
            dp[i]=False
    if dp[k]:
        print("First")
    else:
        print("Second")

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    dp=[0]*(k+1) #0:i個だったら必ず負ける，正:勝つ
    for i in range(min(A),k+1):
        for a in A:
            if i-a>=0 and dp[i-a]==0:
                dp[i]=1
                break
        else:
            dp[i]=0
    if dp[k]==0:
        print("Second")
    else:
        print("First")

if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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(1, k+1):
        for j in range(n):
            if A[j] > i: break
            if not dp[i - A[j]]: 
                dp[i] = True
                break
    return "First" if dp[k] else "Second"
print(solve())

Submission status: Accepted

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

Submission status: Accepted

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

    dp = [0] * (k + 1)  # 石がi個で手番が回ってきたら勝てる：1、負ける：0
    for i1 in range(1, k + 1):  # i1：手番が回ってきた時点の石の残数。残数１から始めてｋまでみる。
        for i2 in range(n):
            if i1 - a[i2] >= 0:  # i1-a[i2]がマイナスだと(スライスにより)意図しない値を見てしまうのでパス。
                if dp[i1 - a[i2]] == 0:  # 相手の負けになるようにできるなら、こちらが勝てる。
                    dp[i1] = 1
    if dp[k] == 1:
        print('First')
    else:
        print('Second')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n , k = IN()
	al = LIN()
	#s = input()
	rr = ['0']*(k+1)
	
	for i in range(k+1):
		if i < al[0]:
			rr[i]='l'
		
		for v in al:
			if v > i:
				pass
			if rr[i-v] == 'l':
				rr[i]='w'
				break
		else:
			rr[i]='l'
	ret = 'First' if rr[-1] == 'w' else 'Second'
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

Solution code:


def main():
    n, K = map(int, input().split())
    a = list(map(int, input().split()))

    # dp[i] is true if First player wins with i tiles left
    dp = [False]*(K+1)
    for k in range(1, K+1):
        for i in a:
            if k >= i and not dp[k-i]:
                dp[k] = True
    print(['Second', 'First'][dp[K]])


if __name__ == "__main__":
    main()

Submission status: Accepted

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

dp = [0] * (k + 1)  #-1=lose,1=win

for i in range(k + 1):
    list = [j for j in a if i >= j]
    if any(dp[i - j] == -1  for j in list):
        dp[i] = 1
    else:
        dp[i] = -1
print('First' if dp[k] == 1 else 'Second')

Submission status: Accepted

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

dp = [0] * (k + 1)  #-1=lose,1=win

for i in range(k + 1):
    if any(dp[i - j] == -1 if i >= j else False for j in a):
        dp[i] = 1
    else:
        dp[i] = -1
print('First' if dp[k] == 1 else 'Second')

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1, K + 1):
    for a in A:
        if i >= a:
            dp[i] |= dp[i - a] ^ True
print('First' if dp[K] else 'Second')

Submission status: Accepted

Solution code:
def main():
    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-i]==False:
          dp[j]=True
    if dp[k]:
      print('First')
    else:
      print('Second')
main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [False] * (k + 1)

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

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=sorted(map(int,input().split()))
d=[0]*(K+1)
for i in range(K):
    x=d[i]^1
    if x:
        for a in A:
            if i+a<K+1:
                d[i+a]=x
print(['Second','First'][d[-1]])

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
sorted(A)
DP = [-1] * (K+1)
for i in range(K+1):
    if i < A[0]:
        DP[i] = False
    else:
        for j in A:
            if i - j <= 0:
                DP[i] = False
            if not DP[i-j]:
                DP[i] = True
                break
            DP[i] = False
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[k+1]=False
dp = [False]*(k+1)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
N,K = LI()
a = LI()
dp = [0 for _ in range(K+1)]

for i in range(K,-1,-1):
    if dp[i]: continue
    for x in a:
        if i-x >= 0: dp[i-x] = 1
if dp[0] == 1:
    print('First')
else:
    print('Second')

Submission status: Accepted

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
N,K = LI()
a = LI()
dp = [0 for _ in range(K+1)]

for i in range(K,-1,-1):
    if dp[i]: continue
    for x in a: dp[i-x] = 1
if dp[0] == 1:
    print('First')
else:
    print('Second')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k, *a= map(int, open(0).read().split())
dp = [0]*(k+1)
for i in range(k+1):
    dp[i] = not all(dp[i-s] for s in a if i-s>=0)
print(['Second','First'][dp[-1]])

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

Solution code:
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy


def solve_me(values, k):
    dp = [0 for _ in range(k)]
    # 1 is 1st player
    dp[k - 1] = 1
    for _ in range(k // min(values)):
        prev = dp.copy()
        # dp[i] which players can have i stones at round (1 first, 2 second, 3 both)
        dp = [0 for _ in range(k)]
        for a in values:
            LOG.debug((a))
            for i in range(a, k):
                # LOG.debug(("i", i, "prev[i]", prev[i]))
                # 1st player is there
                if prev[i] & 1 == 1:
                    # LOG.debug(("player 1", i - a))
                    dp[i - a] |= 2
                # 2nd player is there
                if prev[i] & 2 == 2:
                    # LOG.debug(("player 2", i - a))
                    dp[i - a] |= 1
        LOG.debug((dp))
        if dp[0] > 0:
            return dp[0] & 2
    assert False, dp
    return None


def solve(values, k):
    # dp[i] True if the first player wins if there are i stones remaining
    dp = [False for _ in range(k + 1)]
    for stones in range(k + 1):
        for a in values:
            if stones < a:
                continue
            if not dp[stones - a]:
                dp[stones] = True
        LOG.debug((dp))
    return dp[k]


def do_job():
    "Do the work"
    LOG.debug("Start working")
    # first line is number of test cases
    N, K = list(map(int, input().split()))
    values = list(map(int, input().split()))
    assert len(values) == N
    result = solve(values, K)
    print("First" if result else "Second")


def configure_log():
    "Configure the log output"
    log_formatter = logging.Formatter("L%(lineno)d - " "%(message)s")
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None
# for interactive call: do not add multiple times the handler
if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


class memoized:
    """Decorator that caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned, and
    not re-evaluated.
    """

    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            return self.cache[args]
        except KeyError:
            value = self.func(*args)
            self.cache[args] = value
            return value
        except TypeError:
            # uncachable -- for instance, passing a list as an argument.
            # Better to not cache than to blow up entirely.
            return self.func(*args)

    def __repr__(self):
        """Return the function's docstring."""
        return self.func.__doc__

    def __get__(self, obj, objtype):
        """Support instance methods."""
        return functools.partial(self.__call__, obj)

Submission status: Accepted

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

Submission status: Accepted

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

a.sort()
ans = ['First', 'Second']

dp = [1]*(K+1)

for i in range(K+1):
    if i < a[0]:
        dp[i] = 1
    else:
        flag = False
        for x in a:
            if i-x >= 0 and dp[i-x]:
                dp[i] = 0
                flag = True
                break

print(ans[dp[-1]])

Submission status: Accepted

Solution code:
from collections import deque
from itertools import product
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    # 先手が勝つ: True, 先手が負ける: False
    dp = [False for i in range(K+1)]
    # 石が残りmin(A)未満のとき、操作不可のため負け
    for i in range(min(A)):
        dp[i] = False
    for i in range(min(A), K+1):
        for a in A:
            if i - a >= 0:
                dp[i] |= not dp[i - a]
    return 'First' if dp[K] else 'Second'


if __name__ == "__main__":
    inputs = read()
    print("%s" % solve(*inputs))

Submission status: Accepted

Solution code:
import sys

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 = list(map(int, input().split()))
A.sort()
amin, amax = A[0], A[-1]


def solve():
    dp = [None] * (K + 1)
    for i in range(amin):
        dp[i] = False
    for i in range(amin, K + 1):
        winnable = False
        for a in A:
            j = i - a
            if j < 0:
                break
            assert dp[j] is not None
            if not dp[j]:
                dp[i] = True
                winnable = True
                break
        if not winnable:
            dp[i] = False
    return dp[K]


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

Submission status: Accepted

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

Submission status: Accepted

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

dp=[0]*(k+1)

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
# dp[i]=石の個数が残り i 個の局面が勝ちか負けかを bool 値で表したもの
dp=[False]*(10**5+1)
dp[0]=False
for aa in a:
  dp[aa]=True

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

Submission status: Accepted

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] = False
            break
        if not dp[i-j]:
            dp[i] = True
            break
    else:
        dp[i] = False
print('First' if dp[k] else 'Second')

Submission status: Accepted

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

dp = [False] * (K + 1)
for i in range(1, K + 1):
    dp[i] = not all(dp[i - x] for x in A if i - x >= 0)
print('First' if dp[K] else 'Second')

Submission status: Accepted

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 i in range(k + 1):
        for e in a:
            if i >= e:
                dp[i] = dp[i] or not dp[i - e]
    
    if dp[k]:
        print("First")
    else:
        print("Second")

submit()

Submission status: Accepted

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 = list(map(int,input().split()))

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

#    print(i, dp[i],A+i,dp[A+i])
#print(dp)

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

Submission status: Accepted

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())))
A = list(map(int,input().split()))

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

#    print(i, dp[i],A+i,dp[A+i])
#print(dp)

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

Submission status: Accepted

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())))
#N, K, *A = map(int, open(0).read().split())

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

#    print(i, dp[i],A+i,dp[A+i])
#print(dp)

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

Submission status: Accepted

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())))
N, K, *A = map(int, open(0).read().split())

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

#    print(i, dp[i],A+i,dp[A+i])
#print(dp)

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

Submission status: Accepted

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 = [True for i in range(K + A[-1] + 1)]
for i in range(K):
    if dp[i]:
        for a in A:
            dp[i + a] = False

#    print(i, dp[i],A+i,dp[A+i])
#print(dp)

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

Submission status: Accepted

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

#    print(i, dp[i],A+i,dp[A+i])
#print(dp)

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

Submission status: Accepted

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 = 'First'
else:
    ans = 'Second'
print(ans)

Submission status: Accepted

Solution code:
def main():

    from bisect import bisect_left as bl, bisect_right as br, insort
    import sys
    import heapq
    # from math import *
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return map(int, data().split())
    out = sys.stdout.write
    # sys.setrecursionlimit(100000)

    n, k = mdata()
    a = list(mdata())
    dp = [0]*(k+1)
    for i in range(1, k + 1):
        for j in a:
            if i >= j:
                if dp[i - j] == 0:
                    dp[i] = 1
            if dp[i] == 1:
                break
    print("First" if dp[k] else "Second")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

dp = ['First']*(K+1)
dp[0] = 'Second'
def solve(dp):
    for i in range(1,K+1):
        for j in range(N):
            dp[i] = 'Second'
            if dp[i-A[j]]=='Second':
                dp[i] = 'First'
                break
    ans = dp[K]
    return ans
print(solve(dp))

Submission status: Accepted

Solution code:
def solve(ls, k):
	dp = [False for i in range(k + 1)]
	for i in range(k + 1):
		for stone in ls:
			if stone <= i and not dp[i - stone]:
				dp[i] = True
	return dp[k]


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

Submission status: Accepted

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

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

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