結果

問題 No.3604 Min of Max of Div of Sum
コンテスト
ユーザー askr58
提出日時 2026-07-31 21:32:37
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 331 ms / 2,000 ms
+ 446µs
コード長 992 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,351 ms
コンパイル使用メモリ 200,740 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2026-07-31 21:32:46
合計ジャッジ時間 5,959 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <iomanip>
#include <ranges>
#include <algorithm>
#include <vector>
#include <atcoder/segtree>
using namespace std;
using ll=long long;
double op(double x,double y){
	return max(x,y);
}
double op2(double x,double y){
	return min(x,y);
}
double e(){
	return -1e18;
}
double e2(){
	return 1e18;
}
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a(n),b(n);
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	double ng=0,ok=1e14;
	for(int _=0;_<70;_++){
		double c=(ok+ng)/2;
		vector<double> u(n);
		for(int i=0;i<n;i++)u[i]=a[i]-b[i]*c;
		vector<double> s(n+1);
		for(int i=0;i<n;i++)s[i+1]=s[i]+u[i];
		atcoder::segtree<double,op,e> seg1(s);
		atcoder::segtree<double,op2,e2> seg2(s);
		bool f=true;
		for(int i=0;i<n;i++){
			double x=seg1.prod(i+1,n+1),y=seg2.prod(0,i+1);
			if(x-y<0){
				f=false;
				break;
			}
		}
		if(f)ng=c;
		else ok=c;
	}
	cout<<fixed<<setprecision(10);
	cout<<ok<<endl;
}
			



0