結果
問題 | No.210 探し物はどこですか? |
ユーザー |
![]() |
提出日時 | 2021-11-10 17:26:13 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 287 ms / 2,000 ms |
コード長 | 2,348 bytes |
コンパイル時間 | 2,242 ms |
コンパイル使用メモリ | 78,880 KB |
実行使用メモリ | 53,072 KB |
最終ジャッジ日時 | 2024-11-21 06:20:07 |
合計ジャッジ時間 | 15,298 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
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(); } }