結果
問題 | No.1736 Princess vs. Dragoness |
ユーザー | ks2m |
提出日時 | 2021-11-12 21:29:16 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 234 ms / 2,000 ms |
コード長 | 1,240 bytes |
コンパイル時間 | 2,542 ms |
コンパイル使用メモリ | 79,268 KB |
実行使用メモリ | 47,708 KB |
最終ジャッジ日時 | 2024-11-25 12:09:16 |
合計ジャッジ時間 | 8,357 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Collections; import java.util.PriorityQueue; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int a = Integer.parseInt(sa[1]); int b = Integer.parseInt(sa[2]); int x = Integer.parseInt(sa[3]); int y = Integer.parseInt(sa[4]); sa = br.readLine().split(" "); long[] h = new long[n]; for (int i = 0; i < n; i++) { h[i] = Integer.parseInt(sa[i]); } br.close(); long yb = (long) y * b; long ok = 1000000000000000L; long ng = -1; while (Math.abs(ok - ng) > 1) { long mid = (ok + ng) / 2; PriorityQueue<Long> que = new PriorityQueue<>(Collections.reverseOrder()); for (int i = 0; i < n; i++) { que.add(Math.max(h[i] - mid, 0)); } for (int i = 0; i < a; i++) { que.add(Math.max(que.poll() - x, 0)); } long sum = 0; for (long e : que) { sum += e; } if (sum <= yb) { ok = mid; } else { ng = mid; } } if (ok == 0) { System.out.println("Yes"); } else { System.out.println("No"); } } }