結果

問題 No.73 helloworld
ユーザー DialBirdDialBird
提出日時 2017-02-21 09:34:54
言語 Ruby
(3.2.2)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 1,000 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 11,256 KB
実行使用メモリ 15,320 KB
最終ジャッジ日時 2023-09-12 11:12:08
合計ジャッジ時間 2,044 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,188 KB
testcase_01 AC 82 ms
15,124 KB
testcase_02 AC 82 ms
15,256 KB
testcase_03 AC 80 ms
15,320 KB
testcase_04 AC 81 ms
15,232 KB
testcase_05 AC 81 ms
15,196 KB
testcase_06 AC 81 ms
15,276 KB
testcase_07 AC 82 ms
15,212 KB
testcase_08 AC 81 ms
15,088 KB
testcase_09 AC 81 ms
15,284 KB
testcase_10 AC 81 ms
15,156 KB
testcase_11 AC 80 ms
15,272 KB
testcase_12 AC 82 ms
15,196 KB
testcase_13 AC 81 ms
15,152 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Yukicoder
  def initialize
    alpha_num = 26
    @alphas = Array.new(alpha_num, 0)
    @targets = []

    alpha_num.times do |i|
      @alphas[i] = gets.to_i
    end
  end

  def run
    if check()
      return calc()
    else
      return 0
    end
  end

  private
  
  def check
    necesarry_alpha_idx = [3, 4, 7, 11, 14, 17, 22]
    necesarry_alpha_num = [1, 1, 1, 3, 2, 1, 1]

    necesarry_alpha_idx.each_with_index do |i, idx|
      return false if @alphas[i] < necesarry_alpha_num[idx]
      @targets << @alphas[i]
    end

    true
  end

  def calc
    l_count = @alphas[11]
    o_count = @alphas[14]

    l_max = 0
    2.upto(l_count - 1) do |i|
      atai = i * (i - 1) * (l_count - i) / 2
      l_max = atai > l_max ? atai : l_max
    end

    o_max = 0
    1.upto(o_count - 1) do |i|
      atai = i * (o_count - i)
      o_max = atai > o_max ? atai : o_max
    end
    @targets[3] = l_max
    @targets[4] = o_max

    return @targets.inject(:*)
  end
end

puts Yukicoder.new.run
0