結果

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

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
max_100.txt AC 340 ms
34,752 KB
max_500.txt AC 416 ms
35,300 KB
max_1000.txt AC 436 ms
36,428 KB
rand10_1.txt AC 344 ms
34,292 KB
rand10_2.txt AC 332 ms
34,232 KB
rand10_3.txt AC 360 ms
34,288 KB
rand10_4.txt AC 356 ms
34,124 KB
rand10_5.txt AC 352 ms
34,260 KB
rand10_s_1.txt AC 280 ms
34,060 KB
rand10_s_2.txt AC 280 ms
33,988 KB
rand10_s_3.txt AC 280 ms
34,260 KB
rand10_s_4.txt AC 304 ms
34,224 KB
rand10_s_5.txt AC 316 ms
34,424 KB
rand100_1.txt AC 376 ms
34,496 KB
rand100_2.txt AC 328 ms
34,604 KB
rand100_3.txt AC 388 ms
34,464 KB
rand100_4.txt AC 380 ms
34,236 KB
rand100_5.txt AC 384 ms
34,472 KB
rand100_s_1.txt AC 360 ms
34,432 KB
rand100_s_2.txt AC 356 ms
34,632 KB
rand100_s_3.txt AC 368 ms
34,420 KB
rand100_s_4.txt AC 360 ms
34,336 KB
rand100_s_5.txt AC 364 ms
34,300 KB
rand500_1.txt AC 428 ms
35,472 KB
rand500_2.txt AC 436 ms
35,328 KB
rand500_3.txt AC 444 ms
35,192 KB
rand500_4.txt AC 436 ms
35,148 KB
rand500_5.txt AC 428 ms
35,116 KB
rand500_s_1.txt AC 460 ms
35,160 KB
rand500_s_2.txt AC 448 ms
35,272 KB
rand500_s_3.txt AC 456 ms
35,144 KB
rand500_s_4.txt AC 456 ms
35,320 KB
rand500_s_5.txt AC 456 ms
35,372 KB
rand1000_1.txt AC 472 ms
36,288 KB
rand1000_2.txt AC 476 ms
36,244 KB
rand1000_3.txt AC 472 ms
36,424 KB
rand1000_4.txt AC 460 ms
36,156 KB
rand1000_5.txt AC 468 ms
35,976 KB
rand1000_s_1.txt AC 468 ms
36,256 KB
rand1000_s_2.txt AC 476 ms
36,188 KB
rand1000_s_3.txt AC 472 ms
36,008 KB
rand1000_s_4.txt AC 476 ms
36,000 KB
rand1000_s_5.txt AC 476 ms
36,160 KB
sample1.txt AC 156 ms
34,232 KB
sample2.txt AC 184 ms
34,020 KB
sample3.txt AC 328 ms
34,112 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 < 1000000; 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