結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
16,172 KB
testcase_01 WA -
testcase_02 AC 84 ms
16,172 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 88 ms
16,172 KB
testcase_07 AC 86 ms
16,172 KB
testcase_08 AC 84 ms
16,172 KB
testcase_09 AC 86 ms
16,172 KB
testcase_10 AC 89 ms
16,172 KB
testcase_11 AC 91 ms
16,172 KB
testcase_12 AC 89 ms
16,172 KB
testcase_13 AC 88 ms
16,172 KB
testcase_14 AC 90 ms
16,172 KB
testcase_15 AC 87 ms
16,172 KB
testcase_16 AC 88 ms
16,172 KB
testcase_17 WA -
testcase_18 AC 85 ms
16,172 KB
testcase_19 AC 87 ms
16,172 KB
testcase_20 AC 85 ms
16,172 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 87 ms
16,172 KB
testcase_24 AC 87 ms
16,172 KB
testcase_25 AC 88 ms
16,172 KB
testcase_26 AC 89 ms
16,172 KB
testcase_27 AC 87 ms
16,172 KB
testcase_28 AC 87 ms
16,172 KB
testcase_29 AC 90 ms
16,172 KB
testcase_30 WA -
testcase_31 AC 87 ms
16,172 KB
testcase_32 WA -
testcase_33 AC 123 ms
21,604 KB
testcase_34 AC 132 ms
22,552 KB
testcase_35 WA -
testcase_36 AC 112 ms
19,572 KB
testcase_37 AC 127 ms
21,320 KB
testcase_38 AC 128 ms
21,320 KB
testcase_39 AC 134 ms
22,748 KB
testcase_40 AC 131 ms
22,720 KB
testcase_41 AC 129 ms
22,356 KB
testcase_42 AC 135 ms
22,852 KB
testcase_43 AC 95 ms
17,188 KB
testcase_44 AC 122 ms
20,360 KB
testcase_45 AC 127 ms
22,052 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 92 ms
16,432 KB
testcase_49 AC 131 ms
22,844 KB
testcase_50 WA -
testcase_51 AC 89 ms
16,432 KB
testcase_52 WA -
testcase_53 AC 132 ms
22,848 KB
testcase_54 AC 114 ms
20,080 KB
testcase_55 AC 132 ms
22,936 KB
testcase_56 WA -
testcase_57 AC 137 ms
22,952 KB
testcase_58 AC 95 ms
17,176 KB
testcase_59 AC 130 ms
22,556 KB
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 136 ms
22,944 KB
testcase_63 AC 95 ms
17,376 KB
testcase_64 AC 127 ms
22,356 KB
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 AC 123 ms
21,508 KB
testcase_70 WA -
testcase_71 AC 95 ms
17,484 KB
testcase_72 WA -
testcase_73 WA -
testcase_74 AC 98 ms
17,380 KB
testcase_75 WA -
testcase_76 WA -
testcase_77 AC 126 ms
21,500 KB
testcase_78 WA -
testcase_79 AC 94 ms
17,280 KB
testcase_80 AC 94 ms
17,076 KB
testcase_81 WA -
testcase_82 AC 118 ms
20,452 KB
testcase_83 WA -
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 AC 83 ms
16,172 KB
testcase_94 AC 83 ms
16,172 KB
testcase_95 AC 141 ms
23,928 KB
testcase_96 WA -
testcase_97 AC 143 ms
24,092 KB
testcase_98 WA -
testcase_99 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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(mid, upper) || dfs(lower,mid) # どちらをとっても負手順じゃなければ勝ち
end

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