結果
| 問題 | No.210 探し物はどこですか? |
| コンテスト | |
| ユーザー |
autotaker1984
|
| 提出日時 | 2015-04-08 12:23:41 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 425 ms / 2,000 ms |
| コード長 | 1,323 bytes |
| 記録 | |
| コンパイル時間 | 2,017 ms |
| コンパイル使用メモリ | 83,992 KB |
| 実行使用メモリ | 46,928 KB |
| 最終ジャッジ日時 | 2026-03-25 18:44:45 |
| 合計ジャッジ時間 | 12,565 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 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();
if( ! (1 <= n && n <= 1000) ) return;
double[] p = new double[n];
double[] q = new double[n];
int s = 0;
for( int i = 0; i < n; i++ ) {
double x = in.nextInt();
p[i] = x / 1000;
s += x;
if( !( 0 <= x && x <= 1000) ) return;
}
if( s != 1000 ) return;
for( int i = 0; i < n; i++ ) {
double x = in.nextInt();
q[i] = x / 100;
if( !( 1 <= x && x <= 1000) ) return;
}
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;
int c = 1;
while( c < 3000 * n ) {
Node node = queue.poll();
exp += c * node.p;
node.p *= 1 - q[node.i];
c++;
queue.add(node);
}
System.out.printf("%5f\n",exp);
}
}
autotaker1984