結果

問題 No.453 製薬会社
ユーザー GrenacheGrenache
提出日時 2016-12-04 12:44:01
言語 Java
(openjdk 23)
結果
AC  
実行時間 870 ms / 2,000 ms
コード長 1,129 bytes
コンパイル時間 3,551 ms
コンパイル使用メモリ 77,560 KB
実行使用メモリ 41,728 KB
最終ジャッジ日時 2024-11-27 19:43:28
合計ジャッジ時間 15,870 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder453 {

	private static Scanner sc;
	private static Printer pr;

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

		double max = 0;
		for (int i = 0; i < 1_000_000; i++) {
			double x = (double)c * i / 1_000_000;

			double l = 0;
			double r = d;
			for (int j = 0; j < 40; j++) {
				double c1 = (l + l + r) / 3;
				double c2 = (l + r + r) / 3;

				if (f(c1, x, c, d) < f(c2, x, c, d)) {
					l = c1;
				} else {
					r = c2;
				}
			}

			max = Math.max(max, f(r, x, c, d));
		}

//		pr.printf("%.7f\n", ret);
		pr.println(max);
	}

	private static double f(double y, double x, int c, int d) {
		double ret = Math.min(x * 4 / 3, y * 4) * 1000 + Math.min((c - x) * 7 / 2, (d - y) * 7 / 5) * 2000;
		return ret;
	}

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

		solve();

		pr.close();
		sc.close();
	}

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