結果
| 問題 | No.825 賢いお買い物 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-03-04 09:25:38 | 
| 言語 | Ruby (3.4.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 89 ms / 2,000 ms | 
| コード長 | 415 bytes | 
| コンパイル時間 | 90 ms | 
| コンパイル使用メモリ | 7,552 KB | 
| 実行使用メモリ | 12,416 KB | 
| 最終ジャッジ日時 | 2024-10-13 23:32:55 | 
| 合計ジャッジ時間 | 2,620 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
コンパイルメッセージ
Syntax OK
ソースコード
# frozen_string_literal: true
def possible?(num1, num10, cost)
  pay = num1 + num10 * 10
  pay >= cost &&
    A + B - num1 - num10 + (pay - cost).divmod(10).sum == C
end
# ---------------------------------------------------------- exec
A, B, C = gets.chomp.split.map(&:to_i)
RESULT = (1..A + 10 * B).find do |cost|
  (0..B).find { |b| (0..A).find { |a| possible?(a, b, cost) } }
end || 'Impossible'
puts RESULT
            
            
            
        