結果
| 問題 |
No.210 探し物はどこですか?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-08 19:08:18 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 456 ms / 2,000 ms |
| コード長 | 1,061 bytes |
| コンパイル時間 | 3,616 ms |
| コンパイル使用メモリ | 78,284 KB |
| 実行使用メモリ | 58,940 KB |
| 最終ジャッジ日時 | 2024-07-06 14:49:33 |
| 合計ジャッジ時間 | 15,432 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main_yukicoder210 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] p = new int[n];
int[] q = new int[n];
for (int i = 0; i < n; i++) {
p[i] = sc.nextInt();
}
for (int i = 0; i < n; i++) {
q[i] = sc.nextInt();
}
PriorityQueue<Foo> pq = new PriorityQueue<Foo>();
for (int i = 0; i < n; i++) {
pq.add(new Foo((double)p[i] * q[i] / 100000, i));
}
double ret = 0.0;
final double EPS = 1.e-9;
for (int i = 1; i < 1000000; i++) {
Foo tmp = pq.poll();
ret += tmp.p * i;
tmp.p *= 1.0 - (double)q[tmp.i] / 100;
if (tmp.p != 0.0 && tmp.p * i < EPS) {
break;
}
pq.add(tmp);
}
System.out.printf("%.6f\n", ret);
sc.close();
}
private static class Foo implements Comparable<Foo> {
double p;
int i;
public Foo(double p, int i) {
this.p = p;
this.i = i;
}
@Override
public int compareTo(Foo o) {
return Double.compare(o.p, this.p);
}
}
}