結果

問題 No.210 探し物はどこですか?
ユーザー koyumeishi
提出日時 2015-05-16 01:07:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-06 04:38:04
合計ジャッジ時間 6,635 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<double> p(n), q(n);
	const double p_ = 1.0/1000;
	const double q_ = 1.0/100;

	for(int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		p[i] = tmp * p_;
	}
	for(int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		q[i] = tmp * q_;
	}

	double ans = 0.0;

	priority_queue<pair<double, pair<double,int>>> pq;
	for(int i=0; i<n; i++){
		pq.push({p[i] * q[i], {p[i], i}});
	}

	for(int i=1; i<=1000000; ++i){
		auto val = pq.top(); pq.pop();
		ans += i * val.first;
		double p_next = val.second.first * (1.0 - q[val.second.second]);
		pq.push({p_next * q[val.second.second], {p_next, val.second.second}});
	}

	printf("%.16f\n", ans);
	return 0;
}
0