結果

問題 No.210 探し物はどこですか?
ユーザー 沙耶花
提出日時 2021-11-04 21:10:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,476 ms / 2,000 ms
コード長 1,152 bytes
コンパイル時間 4,958 ms
コンパイル使用メモリ 257,404 KB
最終ジャッジ日時 2025-01-25 11:44:39
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000000000
using P = pair<double,int>;
P op(P a,P b){
	return max(a,b);
}
P e(){
	return make_pair(0.0,-1);
}

P mapping(double a,P b){
	b.first *= a;
	return b;
}

double composition(double a,double b){
	return a*b;
}

double id(){
	return 1.0;
}

int main(){	
	
	int n;
	cin>>n;
	
	vector<double> p(n),q(n);
	rep(i,n){
		cin>>p[i];
		p[i] /= 1000.0;
	}
	rep(i,n){
		cin>>q[i];
		q[i] /= 100.0;
	}	
	
	double ans = 0.0;
	double pp = 1.0;
	
	vector<P> temp(n);
	rep(i,n)temp[i] = make_pair(p[i]*q[i],i);
	
	lazy_segtree<P,op,e,double,mapping,composition,id> seg(temp);

	rep(_,1000000){
		ans += pp;
		P r = seg.all_prod();
		if(r.second==-1)break;
		pp *= 1.0 - r.first;
		double ps = 1.0;
		r.first /= q[r.second];
		ps -= r.first;
		r.first *= 1.0 - q[r.second];
		ps += r.first;
		r.first *= q[r.second];
		seg.set(r.second,r);
		if(ps<1e-10)break;
		seg.apply(0,n,1.0 / ps);
	}
	
	cout<<fixed<<setprecision(10)<<ans<<endl;

	return 0;
	
}
0