結果

問題 No.210 探し物はどこですか?
ユーザー tentententen
提出日時 2021-11-10 17:26:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 2,348 bytes
コンパイル時間 1,931 ms
コンパイル使用メモリ 79,280 KB
実行使用メモリ 53,116 KB
最終ジャッジ日時 2024-05-01 05:05:12
合計ジャッジ時間 13,363 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
52,200 KB
testcase_01 AC 178 ms
52,332 KB
testcase_02 AC 213 ms
52,632 KB
testcase_03 AC 227 ms
52,412 KB
testcase_04 AC 231 ms
52,728 KB
testcase_05 AC 226 ms
52,432 KB
testcase_06 AC 225 ms
52,348 KB
testcase_07 AC 239 ms
52,896 KB
testcase_08 AC 219 ms
52,872 KB
testcase_09 AC 183 ms
52,160 KB
testcase_10 AC 223 ms
52,712 KB
testcase_11 AC 238 ms
52,708 KB
testcase_12 AC 230 ms
52,816 KB
testcase_13 AC 208 ms
52,560 KB
testcase_14 AC 203 ms
52,580 KB
testcase_15 AC 238 ms
52,716 KB
testcase_16 AC 215 ms
52,352 KB
testcase_17 AC 248 ms
52,708 KB
testcase_18 AC 195 ms
52,428 KB
testcase_19 AC 198 ms
52,608 KB
testcase_20 AC 197 ms
52,592 KB
testcase_21 AC 213 ms
52,300 KB
testcase_22 AC 203 ms
52,536 KB
testcase_23 AC 221 ms
52,740 KB
testcase_24 AC 225 ms
52,552 KB
testcase_25 AC 236 ms
52,516 KB
testcase_26 AC 224 ms
52,640 KB
testcase_27 AC 228 ms
52,560 KB
testcase_28 AC 231 ms
52,668 KB
testcase_29 AC 233 ms
52,532 KB
testcase_30 AC 222 ms
52,740 KB
testcase_31 AC 218 ms
52,524 KB
testcase_32 AC 222 ms
52,680 KB
testcase_33 AC 234 ms
52,976 KB
testcase_34 AC 237 ms
52,948 KB
testcase_35 AC 242 ms
52,836 KB
testcase_36 AC 231 ms
53,084 KB
testcase_37 AC 239 ms
52,592 KB
testcase_38 AC 246 ms
52,924 KB
testcase_39 AC 244 ms
53,052 KB
testcase_40 AC 244 ms
53,116 KB
testcase_41 AC 250 ms
52,848 KB
testcase_42 AC 253 ms
52,824 KB
testcase_43 AC 80 ms
51,656 KB
testcase_44 AC 105 ms
52,076 KB
testcase_45 AC 221 ms
52,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        Room[] rooms = new Room[n];
        for (int i = 0; i < n; i++) {
            rooms[i] = new Room(sc.nextInt());
        }
        for (int i = 0; i < n; i++) {
            rooms[i].find(sc.nextInt());
        }
        PriorityQueue<Room> queue = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            queue.add(rooms[i]);
        }
        double ans = 0;
        for (int i = 1; i < 1000000; i++) {
            Room r = queue.poll();
            ans += r.rate * i;
            r.add();
            queue.add(r);
            //System.out.println(ans);
        }
        System.out.println(ans);
    }
    
    static class Room implements Comparable<Room> {
        double lostRate;
        double findRate;
        double notFindRate;
        double rate;
        
        public Room(int x) {
            lostRate = x / 1000.0;
        }
        
        public void find(int x) {
            findRate = x / 100.0;
            notFindRate = 1 - findRate;
            rate = lostRate * findRate;
        }
        
        public void add() {
            rate *= notFindRate;
        }
        
        public int compareTo(Room another) {
            if (rate == another.rate) {
                return 0;
            } else if (rate < another.rate) {
                return 1;
            } else {
                return -1;
            }
        }
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0