結果

問題 No.825 賢いお買い物
ユーザー GrenacheGrenache
提出日時 2019-05-04 12:54:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 1,038 bytes
コンパイル時間 5,687 ms
コンパイル使用メモリ 74,168 KB
実行使用メモリ 56,276 KB
最終ジャッジ日時 2023-09-03 22:42:44
合計ジャッジ時間 7,110 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,992 KB
testcase_01 AC 122 ms
55,836 KB
testcase_02 AC 118 ms
56,276 KB
testcase_03 AC 117 ms
55,932 KB
testcase_04 AC 119 ms
55,920 KB
testcase_05 AC 123 ms
56,096 KB
testcase_06 AC 121 ms
55,400 KB
testcase_07 AC 120 ms
55,636 KB
testcase_08 AC 120 ms
55,916 KB
testcase_09 AC 120 ms
56,140 KB
testcase_10 AC 121 ms
55,656 KB
testcase_11 AC 122 ms
55,676 KB
testcase_12 AC 122 ms
55,848 KB
testcase_13 AC 126 ms
55,856 KB
testcase_14 AC 122 ms
56,208 KB
testcase_15 AC 123 ms
55,836 KB
testcase_16 AC 123 ms
55,644 KB
testcase_17 AC 123 ms
56,268 KB
testcase_18 AC 122 ms
55,628 KB
testcase_19 AC 121 ms
55,624 KB
testcase_20 AC 122 ms
55,924 KB
testcase_21 AC 121 ms
56,060 KB
権限があれば一括ダウンロードができます

ソースコード

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