結果
| 問題 | No.3604 Min of Max of Div of Sum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-31 22:02:36 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 161 ms / 2,000 ms |
| + 6µs | |
| コード長 | 1,133 bytes |
| 記録 | |
| コンパイル時間 | 2,359 ms |
| コンパイル使用メモリ | 333,608 KB |
| 実行使用メモリ | 7,424 KB |
| 最終ジャッジ日時 | 2026-07-31 22:02:50 |
| 合計ジャッジ時間 | 5,522 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int n;
cin >> n;
vector<double> a(n), b(n);
rep(i, n) cin >> a[i];
rep(i, n) cin >> b[i];
double ac = 1e14, wa = 0;
rep(ti, 100) {
double wj = (ac+wa)/2;
auto ok = [&]{
vector<double> p(n+1);
rep(i, n) p[i+1] = p[i] + (a[i]-wj*b[i]);
vector<double> lmn(n+1);
double now = p[0];
for (int i = 1; i <= n; ++i) {
lmn[i] = now;
now = min(now, p[i]);
}
vector<double> rmx(n+1);
rmx[n] = p[n];
for (int i = n-1; i >= 1; --i) {
rmx[i] = max(rmx[i+1], p[i]);
}
for (int i = 1; i <= n; ++i) {
if (rmx[i] <= lmn[i]+1e-11) {
return true;
}
}
return false;
}();
(ok ? ac : wa) = wj;
}
printf("%.10f\n", ac);
return 0;
}