結果

問題 No.846 メダル
ユーザー ks2mks2m
提出日時 2019-07-05 21:39:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 794 bytes
コンパイル時間 2,290 ms
コンパイル使用メモリ 79,568 KB
実行使用メモリ 42,604 KB
最終ジャッジ日時 2024-04-16 07:08:16
合計ジャッジ時間 7,183 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
42,300 KB
testcase_01 AC 135 ms
41,296 KB
testcase_02 AC 159 ms
42,176 KB
testcase_03 AC 156 ms
42,196 KB
testcase_04 AC 130 ms
41,108 KB
testcase_05 AC 136 ms
41,108 KB
testcase_06 AC 162 ms
42,228 KB
testcase_07 AC 130 ms
41,272 KB
testcase_08 AC 155 ms
42,188 KB
testcase_09 AC 158 ms
42,604 KB
testcase_10 AC 156 ms
42,228 KB
testcase_11 AC 157 ms
42,300 KB
testcase_12 AC 123 ms
40,060 KB
testcase_13 AC 132 ms
41,056 KB
testcase_14 AC 160 ms
42,472 KB
testcase_15 AC 135 ms
41,412 KB
testcase_16 AC 132 ms
41,168 KB
testcase_17 AC 158 ms
42,156 KB
testcase_18 AC 139 ms
41,344 KB
testcase_19 AC 131 ms
41,540 KB
testcase_20 AC 156 ms
42,104 KB
testcase_21 AC 167 ms
42,096 KB
testcase_22 AC 164 ms
42,148 KB
testcase_23 AC 133 ms
41,128 KB
testcase_24 AC 160 ms
42,292 KB
testcase_25 AC 158 ms
41,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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

		long[] min = new long[3];
		long[] max = new long[3];
		min[0] = (a - 1) * p + 1;
		max[0] = a * p;
		min[1] = (a + b - 1) * q + 1;
		max[1] = (a + b) * q;
		min[2] = (a + b + c - 1) * r + 1;
		max[2] = (a + b + c) * r;

		long ans1 = 0;
		long ans2 = Long.MAX_VALUE;
		for (int i = 0; i < 3; i++) {
			ans1 = Math.max(ans1, min[i]);
			ans2 = Math.min(ans2, max[i]);
		}
		if (ans1 > ans2) {
			System.out.println(-1);
		} else {
			System.out.println(ans1 + " " + ans2);
		}
	}
}
0