結果

問題 No.825 賢いお買い物
ユーザー ks2mks2m
提出日時 2019-05-03 21:46:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 1,984 ms
コンパイル使用メモリ 71,332 KB
実行使用メモリ 58,024 KB
最終ジャッジ日時 2023-08-30 06:03:46
合計ジャッジ時間 5,697 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
56,292 KB
testcase_01 AC 118 ms
55,612 KB
testcase_02 AC 118 ms
58,024 KB
testcase_03 AC 120 ms
56,036 KB
testcase_04 AC 120 ms
56,208 KB
testcase_05 AC 120 ms
55,464 KB
testcase_06 AC 119 ms
56,108 KB
testcase_07 AC 120 ms
56,040 KB
testcase_08 AC 121 ms
56,128 KB
testcase_09 AC 118 ms
56,120 KB
testcase_10 AC 118 ms
56,520 KB
testcase_11 AC 120 ms
56,236 KB
testcase_12 AC 120 ms
56,124 KB
testcase_13 AC 120 ms
55,792 KB
testcase_14 AC 119 ms
55,728 KB
testcase_15 AC 117 ms
55,808 KB
testcase_16 AC 120 ms
55,980 KB
testcase_17 AC 119 ms
55,980 KB
testcase_18 AC 117 ms
55,640 KB
testcase_19 AC 120 ms
55,604 KB
testcase_20 AC 121 ms
55,672 KB
testcase_21 AC 119 ms
55,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();

		if (b == 0) {
			if (a <= c) {
				System.out.println("Impossible");
				return;
			}
		} else {
			if (a + b + 8 < c) {
				System.out.println("Impossible");
				return;
			}
		}

		if (b >= c && a != 0) {
			System.out.println(10 * (b - c) + a);
		} else {
			if (a + b > c) {
				while (a >= 10 && a + b - c >= 10) {
					a -= 10;
					b++;
				}
				System.out.println(a + b - c);
			} else {
				a += 9;
				b--;
				System.out.println(a + b - c + 1);
			}
		}
	}
}
0