結果

問題 No.1453 手助け
ユーザー kanno_kannokanno_kanno
提出日時 2021-04-17 19:33:52
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 693 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 11,428 KB
実行使用メモリ 15,316 KB
最終ジャッジ日時 2023-09-17 05:01:17
合計ジャッジ時間 3,123 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,068 KB
testcase_01 AC 84 ms
15,272 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 82 ms
15,040 KB
testcase_06 WA -
testcase_07 AC 81 ms
15,088 KB
testcase_08 AC 81 ms
15,016 KB
testcase_09 AC 82 ms
15,116 KB
testcase_10 WA -
testcase_11 AC 82 ms
15,248 KB
testcase_12 WA -
testcase_13 AC 82 ms
15,032 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 80 ms
15,304 KB
testcase_17 AC 80 ms
15,252 KB
testcase_18 WA -
testcase_19 AC 82 ms
15,264 KB
testcase_20 WA -
testcase_21 AC 83 ms
15,048 KB
testcase_22 AC 82 ms
15,100 KB
testcase_23 AC 79 ms
15,100 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def solve
  nums = gets.chomp.split.map(&:to_i)
  if nums[1] <= nums[2] # 参加者がいない場合
    puts 0
  else
    price_by_person = calc_by_person(nums)
    total_price = price_by_person * (nums[1] - nums[2])
    puts total_price
  end
end

def calc_by_person(nums)
  d_price = nums[3]
  return d_price if nums[0] <= 1

  prices_of_drops = [d_price]
  # 渡す個数に応じて計算
  (2..nums[0]).each do |i|
    x = prices_of_drops.last
    if (i % 10).zero?
      e = nums[4] # E price
      if e <= x
        prices_of_drops << [x - e, 0].max
      else
        prices_of_drops << x
      end
    else
      prices_of_drops << x
    end
  end

  prices_of_drops.sum
end

solve
0