結果
問題 |
No.761 平均値ゲーム
|
ユーザー |
![]() |
提出日時 | 2020-12-20 01:48:28 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 443 ms / 2,000 ms |
コード長 | 651 bytes |
コンパイル時間 | 112 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 50,420 KB |
最終ジャッジ日時 | 2024-09-21 11:16:21 |
合計ジャッジ時間 | 22,215 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
from functools import lru_cache import bisect from itertools import accumulate eps = 1e-10 N = int(input()) A = list(map(int, input().split())) B = list(accumulate(A, initial=0)) @lru_cache(maxsize=None) def grundy(l, r): if r == l: return 0 if r - l == 1: return 1 sm = B[r] - B[l] sz = r - l m = bisect.bisect_left(A, sm / sz - eps) if l == m: return 1 tmp = set() tmp.add(grundy(l, m)) tmp.add(grundy(m, r)) for i, v in enumerate(sorted(tmp)): if i == v: continue return i return i + 1 if grundy(0, N): print("First") else: print("Second")