結果

問題 No.453 製薬会社
ユーザー GrenacheGrenache
提出日時 2016-12-04 12:57:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 1,353 bytes
コンパイル時間 3,143 ms
コンパイル使用メモリ 78,120 KB
実行使用メモリ 41,580 KB
最終ジャッジ日時 2024-05-05 19:19:18
合計ジャッジ時間 5,318 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
40,236 KB
testcase_01 AC 119 ms
41,344 KB
testcase_02 AC 119 ms
41,300 KB
testcase_03 AC 115 ms
41,304 KB
testcase_04 AC 118 ms
41,276 KB
testcase_05 AC 119 ms
40,972 KB
testcase_06 AC 112 ms
40,240 KB
testcase_07 AC 122 ms
41,448 KB
testcase_08 AC 109 ms
40,284 KB
testcase_09 AC 109 ms
39,984 KB
testcase_10 AC 119 ms
41,308 KB
testcase_11 AC 126 ms
41,580 KB
testcase_12 AC 125 ms
41,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder453_1 {

	private static Scanner sc;
	private static Printer pr;

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

		double max = 0;
		double lx = 0;
		double rx = c;
		for (int i = 0; i < 100; i++) {
			double c1x = (lx + lx + rx) / 3;
			double c2x = (lx + rx + rx) / 3;

			if (fx(c1x, c, d) < fx(c2x, c, d)) {
				lx = c1x;
			} else {
				rx = c2x;
			}

			max = Math.max(max, fx(rx, c, d));
		}

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

	private static double fx(double c1x, int c, int d) {
		double l = 0;
		double r = d;
		for (int j = 0; j < 100; j++) {
			double c1 = (l + l + r) / 3;
			double c2 = (l + r + r) / 3;

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

		return f(r, c1x, c, d);
	}

	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