結果
問題 | No.210 探し物はどこですか? |
ユーザー |
![]() |
提出日時 | 2016-09-15 22:21:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 765 ms / 2,000 ms |
コード長 | 1,654 bytes |
コンパイル時間 | 1,996 ms |
コンパイル使用メモリ | 174,812 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-17 06:15:36 |
合計ジャッジ時間 | 12,444 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#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 <= 1000000; 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; }