結果

問題 No.825 賢いお買い物
ユーザー Grenache
提出日時 2019-05-04 12:54:48
言語 Java
(openjdk 23)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 1,038 bytes
コンパイル時間 4,575 ms
コンパイル使用メモリ 78,296 KB
実行使用メモリ 55,968 KB
最終ジャッジ日時 2024-06-13 03:20:02
合計ジャッジ時間 7,197 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.Scanner;


public class Main_yukicoder825 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int min = Integer.MAX_VALUE;
		for (int aa = 0; aa <= a; aa++) {
			for (int bb = 0; bb <= b; bb++) {
				int pay = aa + 10 * bb;
				for (int i = 1; i <= pay; i++) {
					int cnt = a - aa + b - bb;
					cnt += (pay - i) / 10;
					cnt += (pay - i) % 10;
					if (cnt == c) {
//						pr.printf("%d %d %d %d%n", aa, bb, pay, i);
						min = Math.min(min, i);
					}
				}
			}
		}
		
		if (min == Integer.MAX_VALUE) {
			pr.println("Impossible");
		} else {
			pr.println(min);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0