結果

問題 No.210 探し物はどこですか?
ユーザー htensai
提出日時 2020-01-15 12:33:07
言語 Java11
(openjdk 11.0.5)
結果
WA   .
実行時間 -
コード長 1,314 Byte
コンパイル時間 3,068 ms
使用メモリ 36,100 KB
最終ジャッジ日時 2020-01-15 12:33:25

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
max_100.txt AC 200 ms
34,156 KB
max_500.txt WA -
max_1000.txt WA -
rand10_1.txt AC 172 ms
34,184 KB
rand10_2.txt AC 168 ms
34,152 KB
rand10_3.txt AC 172 ms
34,160 KB
rand10_4.txt AC 176 ms
34,192 KB
rand10_5.txt AC 172 ms
34,224 KB
rand10_s_1.txt AC 168 ms
34,144 KB
rand10_s_2.txt AC 172 ms
34,096 KB
rand10_s_3.txt AC 172 ms
34,420 KB
rand10_s_4.txt AC 164 ms
33,940 KB
rand10_s_5.txt AC 168 ms
34,280 KB
rand100_1.txt AC 208 ms
34,416 KB
rand100_2.txt AC 216 ms
34,604 KB
rand100_3.txt AC 204 ms
34,528 KB
rand100_4.txt AC 200 ms
34,276 KB
rand100_5.txt AC 200 ms
34,172 KB
rand100_s_1.txt AC 200 ms
34,140 KB
rand100_s_2.txt AC 196 ms
34,364 KB
rand100_s_3.txt AC 204 ms
34,116 KB
rand100_s_4.txt AC 192 ms
34,408 KB
rand100_s_5.txt AC 204 ms
34,168 KB
rand500_1.txt AC 224 ms
35,148 KB
rand500_2.txt AC 220 ms
35,232 KB
rand500_3.txt AC 228 ms
35,212 KB
rand500_4.txt AC 220 ms
35,276 KB
rand500_5.txt AC 220 ms
35,124 KB
rand500_s_1.txt WA -
rand500_s_2.txt WA -
rand500_s_3.txt WA -
rand500_s_4.txt WA -
rand500_s_5.txt WA -
rand1000_1.txt AC 220 ms
35,824 KB
rand1000_2.txt AC 224 ms
35,816 KB
rand1000_3.txt AC 220 ms
36,088 KB
rand1000_4.txt AC 220 ms
35,804 KB
rand1000_5.txt AC 220 ms
35,756 KB
rand1000_s_1.txt WA -
rand1000_s_2.txt WA -
rand1000_s_3.txt WA -
rand1000_s_4.txt WA -
rand1000_s_5.txt WA -
sample1.txt AC 152 ms
34,040 KB
sample2.txt AC 156 ms
34,064 KB
sample3.txt AC 172 ms
34,200 KB
テストケース一括ダウンロード

ソースコード

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