結果

問題 No.825 賢いお買い物
コンテスト
ユーザー kat0rik
提出日時 2020-02-03 22:16:42
言語 Go
(1.27.0 + ACL)
コンパイル:
/usr/bin/go_c
実行:
./Main
結果
WA  
実行時間 -
コード長 655 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,396 ms
コンパイル使用メモリ 266,328 KB
実行使用メモリ 9,800 KB
最終ジャッジ日時 2026-08-30 21:55:54
合計ジャッジ時間 10,925 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package main

import "fmt"

var inf = int(1e9) + 1

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)
	if C <= A+B {
		ans := inf
		for c := 1; c <= A+10*B; c++ {
			for x := 0; x <= A; x++ {
				for y := 0; y <= B; y++ {
					// c円の品物を1G x枚、10G y枚で支払ったときのお釣りを含めた残枚数がCとなるときを追跡する
					pay := x + 10*y
					change := (pay-c)/10 + (pay-c)%10
					if pay >= c && (A-x)+(B-y)+change == C {
						ans = min(ans, c)
					}
				}
			}
		}
		if ans != inf {
			fmt.Println(ans)
			return
		}
	}
	fmt.Println("Impossible")
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
0