結果

問題 No.761 平均値ゲーム
ユーザー rlangevin
提出日時 2024-04-10 12:18:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 619 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 93,952 KB
最終ジャッジ日時 2024-10-02 14:18:11
合計ジャッジ時間 11,051 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)

def BinarySearch(yes, no):
    L, R = yes, no
    while abs(yes - no) != 1:
        mid = (yes + no)//2
        if A[mid] * (R - L) < Ac[R] - Ac[L]:
            yes = mid
        else:
            no = mid
    return yes

N = int(input())
A = sorted(list(map(int, input().split())))
Ac = [0] * (N + 1)
for i in range(N):
    Ac[i + 1] = Ac[i] + A[i]

def dfs(L, R):
    if R <= L:
        return 0
    if A[L] == A[R - 1]:
        return 1
    ind = BinarySearch(L, R)
    return dfs(L, ind + 1) == 0 or dfs(ind + 1, R) == 0
    
print("First") if dfs(0, N) else print("Second")
0