結果

問題 No.453 製薬会社
ユーザー GrenacheGrenache
提出日時 2016-12-04 12:57:12
言語 Java19
(openjdk 21)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 1,353 bytes
コンパイル時間 6,678 ms
コンパイル使用メモリ 74,640 KB
実行使用メモリ 56,592 KB
最終ジャッジ日時 2023-08-18 14:08:22
合計ジャッジ時間 6,130 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,556 KB
testcase_01 AC 127 ms
53,748 KB
testcase_02 AC 128 ms
55,968 KB
testcase_03 AC 127 ms
55,824 KB
testcase_04 AC 125 ms
55,560 KB
testcase_05 AC 126 ms
55,692 KB
testcase_06 AC 125 ms
55,940 KB
testcase_07 AC 124 ms
53,600 KB
testcase_08 AC 125 ms
56,592 KB
testcase_09 AC 126 ms
55,948 KB
testcase_10 AC 126 ms
55,936 KB
testcase_11 AC 125 ms
55,896 KB
testcase_12 AC 127 ms
55,840 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