結果

問題 No.73 helloworld
ユーザー tshigtshig
提出日時 2016-08-05 13:52:10
言語 Ruby
(3.3.0)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 637 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 11,512 KB
実行使用メモリ 15,276 KB
最終ジャッジ日時 2023-09-12 01:08:15
合計ジャッジ時間 2,132 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,140 KB
testcase_01 AC 78 ms
15,276 KB
testcase_02 AC 78 ms
15,128 KB
testcase_03 AC 78 ms
15,132 KB
testcase_04 AC 83 ms
15,036 KB
testcase_05 AC 80 ms
15,168 KB
testcase_06 AC 78 ms
15,228 KB
testcase_07 AC 77 ms
15,052 KB
testcase_08 AC 77 ms
15,044 KB
testcase_09 AC 78 ms
15,248 KB
testcase_10 AC 79 ms
15,084 KB
testcase_11 AC 77 ms
15,160 KB
testcase_12 AC 77 ms
15,044 KB
testcase_13 AC 77 ms
15,088 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Calc0073
  def initialize(args)
    args = args.map { |l| l.chomp.split(/\s+/) }
    @cs = args.map(&:first).map(&:to_i).map.with_index { |c, i|
      [(i + 'a'.ord).chr, c]
    }.to_h
  end

  def run
    rs = %w(h e w r d).map { |a| @cs[a] }
    rs += [calc_o, calc_l]
    rs.inject(:*)
  end

  def calc_o
    o = @cs['o']
    if o < 2
      0
    else
      (1..(o / 2)).map { |k| k * (o - k) }.max
    end
  end

  def calc_l
    c = @cs['l']
    if c < 3
      0
    else
      (2..(c - 1)).map { |k| (1..k).to_a.combination(2).size * (c - k) }.max
    end
  end
end

puts Calc0073.new(STDIN.readlines).run if __FILE__ == $0
0