結果
問題 | No.210 探し物はどこですか? |
ユーザー |
|
提出日時 | 2016-02-18 12:17:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 78 ms / 2,000 ms |
コード長 | 931 bytes |
コンパイル時間 | 718 ms |
コンパイル使用メモリ | 67,504 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 11:55:48 |
合計ジャッジ時間 | 3,993 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:28:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 28 | scanf("%lf", &p[i]); | ~~~~~^~~~~~~~~~~~~~ main.cpp:32:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%lf", &q[i]); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#define _CRT_SECURE_NO_WARNINGS#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>#include<iostream>#include<vector>#include<queue>using namespace std;const int maxn = 1e6;double p[1005], dp[1005],q[1005];int n;typedef struct Value{double v;int x;Value(double v = 0, int x = 0) :v(v), x(x){}friend bool operator < (Value a, Value b){return a.v < b.v;}}Value;priority_queue<Value> Q;double v(int x){return p[x] * (1 - dp[x]) * q[x];}int main(){cin >> n;for (int i = 0; i < n; i++){scanf("%lf", &p[i]);p[i] /= 1e3;}for (int i = 0; i < n; i++){scanf("%lf", &q[i]);q[i] /= 1e2;}double g = 0;for (int i = 0; i < n; i++) Q.push(Value(v(i), i));for (int i = 1; i < maxn; i++){if (i%10000 == 0){int k = 0;}int x = Q.top().x;Q.pop();g += i * v(x);dp[x] += (1 - dp[x]) * q[x];Q.push(Value(v(x), x));}printf("%.7lf\n", g);return 0;}