結果

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

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
max_100.txt AC 1,932 ms
35,740 KB
max_500.txt TLE -
max_1000.txt TLE -
rand10_1.txt TLE -
rand10_2.txt TLE -
rand10_3.txt TLE -
rand10_4.txt TLE -
rand10_5.txt TLE -
rand10_s_1.txt AC 1,756 ms
34,176 KB
rand10_s_2.txt AC 1,764 ms
34,100 KB
rand10_s_3.txt AC 1,764 ms
33,992 KB
rand10_s_4.txt TLE -
rand10_s_5.txt TLE -
rand100_1.txt TLE -
rand100_2.txt AC 1,820 ms
34,288 KB
rand100_3.txt TLE -
rand100_4.txt TLE -
rand100_5.txt TLE -
rand100_s_1.txt AC 1,996 ms
34,200 KB
rand100_s_2.txt TLE -
rand100_s_3.txt TLE -
rand100_s_4.txt AC 1,996 ms
34,276 KB
rand100_s_5.txt AC 1,996 ms
34,204 KB
rand500_1.txt AC 1,980 ms
35,384 KB
rand500_2.txt TLE -
rand500_3.txt TLE -
rand500_4.txt TLE -
rand500_5.txt -- -
rand500_s_1.txt -- -
rand500_s_2.txt -- -
rand500_s_3.txt -- -
rand500_s_4.txt -- -
rand500_s_5.txt -- -
rand1000_1.txt -- -
rand1000_2.txt -- -
rand1000_3.txt -- -
rand1000_4.txt -- -
rand1000_5.txt -- -
rand1000_s_1.txt -- -
rand1000_s_2.txt -- -
rand1000_s_3.txt -- -
rand1000_s_4.txt -- -
rand1000_s_5.txt -- -
sample1.txt -- -
sample2.txt -- -
sample3.txt -- -
テストケース一括ダウンロード

ソースコード

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 < 10000000; 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