結果

問題 No.210 探し物はどこですか?
ユーザー tentententen
提出日時 2021-11-10 17:26:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 302 ms / 2,000 ms
コード長 2,348 bytes
コンパイル時間 2,803 ms
コンパイル使用メモリ 75,012 KB
実行使用メモリ 53,832 KB
最終ジャッジ日時 2023-08-13 11:47:32
合計ジャッジ時間 16,826 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
52,680 KB
testcase_01 AC 211 ms
52,944 KB
testcase_02 AC 231 ms
53,556 KB
testcase_03 AC 270 ms
53,288 KB
testcase_04 AC 266 ms
53,292 KB
testcase_05 AC 264 ms
52,832 KB
testcase_06 AC 278 ms
53,436 KB
testcase_07 AC 277 ms
53,304 KB
testcase_08 AC 271 ms
52,876 KB
testcase_09 AC 213 ms
53,000 KB
testcase_10 AC 266 ms
53,160 KB
testcase_11 AC 285 ms
53,832 KB
testcase_12 AC 294 ms
53,684 KB
testcase_13 AC 239 ms
52,404 KB
testcase_14 AC 242 ms
53,048 KB
testcase_15 AC 301 ms
53,688 KB
testcase_16 AC 253 ms
53,164 KB
testcase_17 AC 294 ms
52,800 KB
testcase_18 AC 241 ms
53,036 KB
testcase_19 AC 237 ms
52,824 KB
testcase_20 AC 239 ms
53,164 KB
testcase_21 AC 241 ms
53,200 KB
testcase_22 AC 239 ms
53,168 KB
testcase_23 AC 262 ms
53,344 KB
testcase_24 AC 269 ms
53,716 KB
testcase_25 AC 265 ms
53,264 KB
testcase_26 AC 267 ms
53,368 KB
testcase_27 AC 261 ms
53,448 KB
testcase_28 AC 277 ms
52,836 KB
testcase_29 AC 275 ms
53,120 KB
testcase_30 AC 279 ms
53,432 KB
testcase_31 AC 272 ms
53,272 KB
testcase_32 AC 271 ms
53,540 KB
testcase_33 AC 292 ms
53,248 KB
testcase_34 AC 293 ms
53,428 KB
testcase_35 AC 300 ms
53,412 KB
testcase_36 AC 293 ms
53,244 KB
testcase_37 AC 294 ms
53,568 KB
testcase_38 AC 298 ms
53,440 KB
testcase_39 AC 292 ms
53,124 KB
testcase_40 AC 297 ms
53,216 KB
testcase_41 AC 302 ms
53,392 KB
testcase_42 AC 287 ms
53,240 KB
testcase_43 AC 77 ms
52,116 KB
testcase_44 AC 107 ms
52,348 KB
testcase_45 AC 263 ms
53,184 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