結果

問題 No.210 探し物はどこですか?
ユーザー htensai
提出日時 2020-01-15 12:33:07
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,314 bytes
コンパイル時間 2,882 ms
コンパイル使用メモリ 78,324 KB
実行使用メモリ 58,484 KB
最終ジャッジ日時 2024-12-31 22:13:01
合計ジャッジ時間 14,198 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        PriorityQueue<Room> queue = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            queue.add(new Room(arr[i], sc.nextInt()));
        }
        double expect = 0;
        for (int i = 1; i < 100000; i++) {
            Room r = queue.poll();
            expect += r.allRate * i;
            r.next();
            queue.add(r);
        }
        System.out.println(expect);
    }
    
    static class Room implements Comparable<Room> {
        double rate;
        double allRate;
        
        public Room (int rate1, int rate2) {
            rate = rate2 / 100.0;
            allRate = rate1 / 1000.0 * rate;
            rate = 1 - rate;
        }
        
        public int compareTo(Room another) {
            if (allRate == another.allRate) {
                return 0;
            } else if (allRate > another.allRate) {
                return -1;
            } else {
                return 1;
            }
        }
        
        public void next() {
            allRate *= rate;
        }
    }
}
0