結果
| 問題 |
No.453 製薬会社
|
| ユーザー |
|
| 提出日時 | 2016-12-04 12:57:12 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 145 ms / 2,000 ms |
| コード長 | 1,353 bytes |
| コンパイル時間 | 3,921 ms |
| コンパイル使用メモリ | 77,652 KB |
| 実行使用メモリ | 41,680 KB |
| 最終ジャッジ日時 | 2024-11-27 19:44:01 |
| 合計ジャッジ時間 | 6,351 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 |
ソースコード
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);
}
}
}