結果

問題 No.825 賢いお買い物
ユーザー maimai
提出日時 2019-05-03 21:48:16
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 480 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 11,536 KB
実行使用メモリ 15,364 KB
最終ジャッジ日時 2023-08-30 06:04:26
合計ジャッジ時間 2,879 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,304 KB
testcase_01 AC 83 ms
15,140 KB
testcase_02 AC 80 ms
15,320 KB
testcase_03 AC 79 ms
15,300 KB
testcase_04 AC 78 ms
15,356 KB
testcase_05 WA -
testcase_06 AC 78 ms
15,160 KB
testcase_07 AC 79 ms
15,152 KB
testcase_08 WA -
testcase_09 AC 79 ms
15,300 KB
testcase_10 AC 79 ms
15,132 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 78 ms
15,132 KB
testcase_14 AC 78 ms
15,328 KB
testcase_15 AC 78 ms
15,092 KB
testcase_16 WA -
testcase_17 AC 78 ms
15,300 KB
testcase_18 WA -
testcase_19 AC 78 ms
15,156 KB
testcase_20 AC 79 ms
15,160 KB
testcase_21 AC 79 ms
15,304 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def lscan;gets.split.map(&:to_i);end

# 1Gの商品を 1G 10x+1枚 => コスト1で10x+1-x = 9x+1減らす

@a, @b, @c = lscan

# 減らしたい枚数
r = @a+@b-@c

if @a + @b < @c
  puts "Impossible" # 10Gを1Gで支払えば増やせるのでWA
  exit
elsif @a + @b == @c
  if @b == 0
    puts "Impossible"
  else
    p 9
  end
    
  exit
else
  cost = 1
  x = ([r, @a].min - 1) / 9
  @a -= 9*x+1
  r -= 9*x+1
  
  a = [r, @a].min
  cost += a
  r -= a
  
  p cost + (r)*10
end
0