結果

問題 No.944 煎っぞ!
ユーザー simansiman
提出日時 2020-09-09 06:13:54
言語 Ruby
(3.3.0)
結果
AC  
実行時間 412 ms / 3,000 ms
コード長 562 bytes
コンパイル時間 462 ms
コンパイル使用メモリ 11,144 KB
実行使用メモリ 21,804 KB
最終ジャッジ日時 2023-08-20 21:37:23
合計ジャッジ時間 7,285 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 151 ms
21,368 KB
testcase_01 AC 143 ms
21,492 KB
testcase_02 AC 147 ms
21,440 KB
testcase_03 AC 146 ms
21,516 KB
testcase_04 AC 155 ms
21,500 KB
testcase_05 AC 140 ms
21,496 KB
testcase_06 AC 144 ms
21,496 KB
testcase_07 AC 146 ms
21,596 KB
testcase_08 AC 155 ms
21,636 KB
testcase_09 AC 141 ms
21,496 KB
testcase_10 AC 92 ms
15,196 KB
testcase_11 AC 106 ms
16,200 KB
testcase_12 AC 100 ms
15,528 KB
testcase_13 AC 93 ms
15,200 KB
testcase_14 AC 103 ms
16,292 KB
testcase_15 AC 99 ms
15,536 KB
testcase_16 AC 93 ms
15,420 KB
testcase_17 AC 94 ms
15,384 KB
testcase_18 AC 107 ms
16,488 KB
testcase_19 AC 107 ms
16,284 KB
testcase_20 AC 141 ms
21,796 KB
testcase_21 AC 143 ms
21,804 KB
testcase_22 AC 151 ms
21,424 KB
testcase_23 AC 160 ms
21,440 KB
testcase_24 AC 173 ms
21,608 KB
testcase_25 AC 158 ms
21,424 KB
testcase_26 AC 156 ms
21,440 KB
testcase_27 AC 196 ms
21,108 KB
testcase_28 AC 95 ms
15,356 KB
testcase_29 AC 95 ms
15,360 KB
testcase_30 AC 152 ms
21,472 KB
testcase_31 AC 412 ms
21,496 KB
testcase_32 AC 238 ms
21,420 KB
testcase_33 AC 178 ms
21,332 KB
testcase_34 AC 177 ms
21,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Integer
  def divisor_list
    require 'prime'

    return [] if self <= 0
    return [1] if self == 1

    prime_division.map.with_index { |(base, k), i|
      s = i.zero? ? 0 : 1
      (s..k).map { |n| base ** n }
    }.inject { |res, e| res + res.flat_map { |t| e.map { |v| t * v } } }.sort
  end
end

N = gets.to_i
A = gets.split.map(&:to_i)
S = A.sum

def f(x)
  sum = 0

  A.each do |a|
    sum += a

    if x < sum
      return false
    elsif x == sum
      sum = 0
    end
  end

  true
end

x = S.divisor_list.select { |x| f(x) }.min

puts S / x
0