Problem:


E: 数列ゲーム

問題文

長さ $N$ の正整数列 $a_1, a_2, \ldots, a_N$ があります。

この数列を用いた、$2$ 人のプレイヤーが先手と後手に分かれて行う以下のゲームを考えます。

先手と後手は交互に、以下の操作のどちらかを選んで行う。

数列の正の項を $1$ つ選び、その値を $1$ 減らす。

数列の全ての項が正のとき、全ての項の値を $1$ ずつ減らす。

先に操作を行えなくなったほうが負けです。

$2$ 人のプレイヤーが最適に行動したとき、先手と後手どちらが勝つかを求めてください。

制約

$1 \leq N \leq 2 \times 10^5$

$1 \leq a_i \leq 10^9$

入力は全て整数である

入力

入力は以下の形式で標準入力から与えられる。

$N$
$a_1$ $a_2$ $...$ $a_N$

出力

先手が勝つときは First を、後手が勝つときは Second を出力せよ。

入力例 1

2
1 2

出力例 1

First

先手が最初に第 $1$ 項の値を $1$ 減らすと、次に後手は第 $2$ 項の値を $1$ 減らすしかありません。

そのあとで先手が第 $2$ 項の値を $1$ 減らすと、数列の全ての項の値は $0$ になり、
後手は操作を行うことができなくなります。

入力例 2

5
3 1 4 1 5

出力例 2

Second

入力例 3

8
2 4 8 16 32 64 128 256

出力例 3

Second

入力例 4

3
999999999 1000000000 1000000000

出力例 4

First



Sample input:
2
1 2


Sample output:
First

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): 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 LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    aa=LI()
    s=sum(aa)
    if n%2:
        if s%2:ans="First"
        else:ans="Second"
    else:
        mn=min(aa)
        if s%2==0 and mn%2==0:ans="Second"
        else:ans="First"
    print(ans)

main()

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    print(["First","Second"][((n&1)&(1^sum(a)&1))|((1^n&1)&(1^sum(a)&1)&(1^min(a)&1))])
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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

if N%2 or 0 in A:
    print('First' if sum(A)%2 else 'Second')
    exit()
if min(A)%2:
    print('First')
else:
    print('First' if sum(A)%2 else 'Second')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
t = min(a)
s = sum(a)

if s%2 or (not n%2 and t%2):
    print('First')
else:
    print('Second')

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    mini=min(A)
    if(N&1):
        if(sum(A)&1):
            print("First")
        else:
            print("Second")
    else:
        if(mini&1):
            print("First")
        else:
            if(sum(A)&1):
                print("First")
            else:
                print("Second")
if __name__ == '__main__':
    main()

Submission status: Accepted

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

if N%2==1:
    if sum(A)%2==1:
        print("First")
    else:
        print("Second")
else:
    if min(A)%2==1:
        print("First")
    else:
        if sum(A)%2==0:
            print("Second")
        else:
            print("First")

Submission status: Accepted

Solution code:
def solve(N,a):
    if N%2 == 1:
        return ["Second","First"][sum(a)%2]
    else:
        if min(a)%2 == 1:
            return "First"
        return ["Second","First"][sum(a)%2]


if __name__ == "__main__":
    N = int(input())
    a = list(map(int,input().split()))
    print(solve(N,a))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math


INF = 10 ** 20

def main():
    n = getN()
    nums = getList()
    sm = sum(nums)
    ans = sm % 2
    if n % 2 == 1:
        if ans == 1:
            print("First")
        else:
            print("Second")
        return
    if n % 2 == 0:
        mn = min(nums)
        if ans == 1:
            if sm == mn * n:
                print("Second")
            else:
                print("First")

        else:
            if mn % 2 == 1:
                print("First")
            else:
                print("Second")

    # print(ans)
    # if ans == 0:
    #     print("Second")
    # else:
    #     print("First")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
X = list(map(int, input().split()))
S = sum(X)
M = min(X)
if N % 2:
    if S%2:
        print("First")
    else:
        print("Second")
else:
    if S%2:
        print("First")
    elif M%2:
        print("First")
    else:
        print("Second")

Submission status: Accepted

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

sum_a = sum(a)
a = sorted(a)

if n % 2 == 1:
    if sum(a) % 2 == 0:
        print("Second")
    else:
        print("First")
    
else:
    if sum_a % 2 == 0 and a[0] % 2 == 0:
        print("Second")
    else:
        print("First")

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
min_a  = min(a)
sum_a  = sum(a)
rest = sum_a - n * min_a

def first():
    print("First")
    exit()

def second():
    print("Second")
    exit()

if n % 2 == 1:
    if sum_a % 2 == 0:second()
    if sum_a % 2 == 1:first()

if min_a % 2 == 1:first()

if rest % 2 == 1:first()
if rest % 2 == 0:second()