結果
| 問題 |
No.210 探し物はどこですか?
|
| コンテスト | |
| ユーザー |
izuru_matsuura
|
| 提出日時 | 2016-09-15 22:20:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,653 bytes |
| コンパイル時間 | 1,751 ms |
| コンパイル使用メモリ | 174,676 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 06:15:15 |
| 合計ジャッジ時間 | 3,536 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
namespace {
typedef double real;
typedef long long ll;
template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
if (vs.empty()) return os << "[]";
auto i = vs.begin();
os << "[" << *i;
for (++i; i != vs.end(); ++i) os << " " << *i;
return os << "]";
}
template<class T> istream& operator>>(istream& is, vector<T>& vs) {
for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
return is;
}
int N;
vector<real> P, Q;
void input() {
cin >> N;
P.resize(N); Q.resize(N);
for (int i = 0; i < N; i++) {
real p; cin >> p; p /= 1000;
P[i] = p;
}
for (int i = 0; i < N; i++) {
real q; cin >> q; q /= 100;
Q[i] = q;
}
}
struct S : pair<real, int> {
S(real a, int b) : pair<real,int>(a, b) {}
bool operator<(const S& o) const {
return first * Q[second] < o.first * Q[o.second];
}
};
void solve() {
priority_queue<S> PQ;
for (int i = 0; i < N; i++) PQ.emplace(P[i], i);
real ans = 1.0;
real mother = 1.0;
for (int t = 1; t <= 100000; t++) {
auto pi = PQ.top(); PQ.pop();
real p = pi.first;
real index = pi.second;
real q = Q[index];
mother -= p * q;
real np = p * (1.0 - q);
ans += mother;
PQ.emplace(np, index);
}
printf("%.12f\n", ans);
}
}
int main() {
input(); solve();
return 0;
}
izuru_matsuura