結果
| 問題 |
No.210 探し物はどこですか?
|
| コンテスト | |
| ユーザー |
autotaker1984
|
| 提出日時 | 2015-04-07 14:55:13 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,461 bytes |
| コンパイル時間 | 2,044 ms |
| コンパイル使用メモリ | 78,748 KB |
| 実行使用メモリ | 58,632 KB |
| 最終ジャッジ日時 | 2024-07-04 10:44:13 |
| 合計ジャッジ時間 | 21,430 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 43 |
ソースコード
import java.util.*;
class Main {
static class Node implements Comparable<Node> {
double p;
int i;
public Node(double p, int i) {
this.p = p;
this.i = i;
}
public int compareTo(Node e) {
if( this.p < e.p )
return 1;
if( this.p > e.p )
return -1;
return 0;
}
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
double[] p = new double[n];
double[] q = new double[n];
for( int i = 0; i < n; i++ ) {
double x = in.nextInt();
p[i] = x / 1000;
}
for( int i = 0; i < n; i++ ) {
double x = in.nextInt();
q[i] = x / 1000;
}
PriorityQueue<Node> queue = new PriorityQueue<Node>();
for( int i = 0; i < n; i++ ) {
if( p[i] > 0 ) {
double x = p[i] * q[i];
queue.add(new Node(x,i));
}
}
double exp = 0;
double rem = 1.0;
int c = 1;
while( !queue.isEmpty() ) {
Node node = queue.poll();
exp += c * node.p;
rem -= node.p;
c++;
//System.err.println(node.i);
if( rem * n * 1000 < exp * 1e-5 ) {
break;
}
/*
if( c % 100000 == 0 ) {
System.err.printf("%.4f %e %d\n",exp,rem,c);
}
*/
node.p *= 1 - q[node.i];
queue.add(node);
}
System.out.printf("%5f\n",exp);
//System.err.println(c);
//System.err.printf("%e\n",rem);
}
}
autotaker1984