結果

問題 No.846 メダル
ユーザー Grenache
提出日時 2019-07-05 22:32:57
言語 Java
(openjdk 23)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 1,054 bytes
コンパイル時間 3,466 ms
コンパイル使用メモリ 77,668 KB
実行使用メモリ 41,696 KB
最終ジャッジ日時 2024-10-06 22:32:12
合計ジャッジ時間 7,992 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder846 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		long p = sc.nextInt();
		long q = sc.nextInt();
		long r = sc.nextInt();
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();

		long min = p * a - (p - 1);
		long max = p * a;
//		pr.printf("%d %d%n", min, max);
		min = Math.max(min, q * (a + b) - (q - 1));
		max = Math.min(max, q * (a + b));
//		pr.printf("%d %d%n", min, max);
		min = Math.max(min, r * (a + b + c) - (r - 1));
		max = Math.min(max, r * (a + b + c));
//		pr.printf("%d %d%n", min, max);
		
		if (min > max) {
			pr.println(-1);
		} else {
			pr.printf("%d %d%n", min, max);
		}
	}

	// ---------------------------------------------------
	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