結果

問題 No.761 平均値ゲーム
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2018-12-21 19:29:09
言語 Ruby
(3.3.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 11,976 KB
実行使用メモリ 24,296 KB
最終ジャッジ日時 2023-10-26 01:34:46
合計ジャッジ時間 13,797 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
16,172 KB
testcase_01 AC 88 ms
16,172 KB
testcase_02 AC 85 ms
16,172 KB
testcase_03 AC 84 ms
16,172 KB
testcase_04 AC 85 ms
16,172 KB
testcase_05 AC 85 ms
16,172 KB
testcase_06 AC 85 ms
16,172 KB
testcase_07 AC 84 ms
16,172 KB
testcase_08 AC 86 ms
16,172 KB
testcase_09 AC 85 ms
16,172 KB
testcase_10 AC 86 ms
16,172 KB
testcase_11 AC 84 ms
16,172 KB
testcase_12 AC 85 ms
16,172 KB
testcase_13 AC 85 ms
16,172 KB
testcase_14 AC 86 ms
16,172 KB
testcase_15 AC 86 ms
16,172 KB
testcase_16 AC 83 ms
16,172 KB
testcase_17 AC 85 ms
16,172 KB
testcase_18 AC 84 ms
16,172 KB
testcase_19 AC 86 ms
16,172 KB
testcase_20 AC 84 ms
16,172 KB
testcase_21 AC 85 ms
16,172 KB
testcase_22 AC 84 ms
16,172 KB
testcase_23 AC 85 ms
16,172 KB
testcase_24 AC 84 ms
16,172 KB
testcase_25 AC 85 ms
16,168 KB
testcase_26 AC 85 ms
16,172 KB
testcase_27 AC 83 ms
16,172 KB
testcase_28 AC 83 ms
16,172 KB
testcase_29 AC 86 ms
16,172 KB
testcase_30 AC 84 ms
16,172 KB
testcase_31 AC 83 ms
16,172 KB
testcase_32 AC 86 ms
16,172 KB
testcase_33 AC 123 ms
21,752 KB
testcase_34 AC 129 ms
22,616 KB
testcase_35 AC 92 ms
16,432 KB
testcase_36 AC 116 ms
19,776 KB
testcase_37 AC 123 ms
21,404 KB
testcase_38 AC 124 ms
21,404 KB
testcase_39 AC 131 ms
22,872 KB
testcase_40 AC 131 ms
22,816 KB
testcase_41 AC 130 ms
22,376 KB
testcase_42 AC 137 ms
23,012 KB
testcase_43 AC 95 ms
17,248 KB
testcase_44 AC 117 ms
20,360 KB
testcase_45 AC 126 ms
22,256 KB
testcase_46 AC 109 ms
19,456 KB
testcase_47 AC 113 ms
19,644 KB
testcase_48 AC 89 ms
16,432 KB
testcase_49 AC 133 ms
22,992 KB
testcase_50 AC 92 ms
16,544 KB
testcase_51 AC 89 ms
16,432 KB
testcase_52 AC 91 ms
16,432 KB
testcase_53 AC 140 ms
23,008 KB
testcase_54 AC 117 ms
20,172 KB
testcase_55 AC 141 ms
22,936 KB
testcase_56 AC 101 ms
18,212 KB
testcase_57 AC 139 ms
22,952 KB
testcase_58 AC 95 ms
17,176 KB
testcase_59 AC 129 ms
22,620 KB
testcase_60 AC 103 ms
18,212 KB
testcase_61 AC 147 ms
24,024 KB
testcase_62 AC 141 ms
22,944 KB
testcase_63 AC 95 ms
17,376 KB
testcase_64 AC 125 ms
22,376 KB
testcase_65 AC 105 ms
18,824 KB
testcase_66 AC 89 ms
16,432 KB
testcase_67 AC 103 ms
18,080 KB
testcase_68 AC 90 ms
16,504 KB
testcase_69 AC 123 ms
21,640 KB
testcase_70 AC 112 ms
19,780 KB
testcase_71 AC 97 ms
17,616 KB
testcase_72 AC 89 ms
16,612 KB
testcase_73 AC 106 ms
18,544 KB
testcase_74 AC 96 ms
17,380 KB
testcase_75 AC 115 ms
19,424 KB
testcase_76 AC 102 ms
18,212 KB
testcase_77 AC 124 ms
21,500 KB
testcase_78 AC 115 ms
19,800 KB
testcase_79 AC 95 ms
17,280 KB
testcase_80 AC 94 ms
17,076 KB
testcase_81 AC 92 ms
16,536 KB
testcase_82 AC 118 ms
20,564 KB
testcase_83 AC 150 ms
24,232 KB
testcase_84 AC 148 ms
24,296 KB
testcase_85 AC 146 ms
24,232 KB
testcase_86 AC 146 ms
24,168 KB
testcase_87 AC 148 ms
24,232 KB
testcase_88 AC 146 ms
24,228 KB
testcase_89 AC 150 ms
24,168 KB
testcase_90 AC 148 ms
24,232 KB
testcase_91 AC 150 ms
24,296 KB
testcase_92 AC 150 ms
24,168 KB
testcase_93 AC 86 ms
16,172 KB
testcase_94 AC 89 ms
16,172 KB
testcase_95 AC 143 ms
23,932 KB
testcase_96 AC 143 ms
24,112 KB
testcase_97 AC 146 ms
24,092 KB
testcase_98 AC 145 ms
23,584 KB
testcase_99 AC 147 ms
24,120 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# URL: https://yukicoder.me/problems/no/761

N = gets.to_i
A = gets.split.map(&:to_i)
S = Array.new(N+1,0)
A.each_with_index do |v,i|
  S[i+1] = S[i] + v
end

def dfs(lower, upper)
  return true if lower + 1 == upper # 1枚で回ってきたときは勝ち
  
  sum = S[upper] - S[lower]
  n = upper - lower
  mid = (lower ... upper).bsearch{|i| A[i] * n >= sum }
  
  return true if mid == lower # 全部とれる場合も勝ち。(区間すべて同じ数)
  
  !(dfs(lower, mid) && dfs(mid, upper)) # 相手の勝手順しかなければ負け
end

puts dfs(0, N) ? 'First' : 'Second'
0