結果

問題 No.1736 Princess vs. Dragoness
ユーザー ks2mks2m
提出日時 2021-11-12 21:29:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 1,240 bytes
コンパイル時間 2,002 ms
コンパイル使用メモリ 79,220 KB
実行使用メモリ 57,616 KB
最終ジャッジ日時 2024-05-04 04:58:11
合計ジャッジ時間 7,366 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
49,996 KB
testcase_01 AC 49 ms
50,372 KB
testcase_02 AC 50 ms
50,424 KB
testcase_03 AC 102 ms
51,776 KB
testcase_04 AC 141 ms
54,196 KB
testcase_05 AC 94 ms
51,832 KB
testcase_06 AC 150 ms
54,712 KB
testcase_07 AC 184 ms
54,632 KB
testcase_08 AC 137 ms
54,560 KB
testcase_09 AC 164 ms
54,408 KB
testcase_10 AC 84 ms
51,516 KB
testcase_11 AC 217 ms
57,616 KB
testcase_12 AC 132 ms
54,144 KB
testcase_13 AC 148 ms
54,716 KB
testcase_14 AC 147 ms
54,844 KB
testcase_15 AC 112 ms
52,104 KB
testcase_16 AC 126 ms
52,092 KB
testcase_17 AC 141 ms
54,532 KB
testcase_18 AC 131 ms
54,180 KB
testcase_19 AC 128 ms
54,316 KB
testcase_20 AC 102 ms
52,544 KB
testcase_21 AC 143 ms
54,356 KB
testcase_22 AC 164 ms
54,576 KB
testcase_23 AC 125 ms
54,316 KB
testcase_24 AC 76 ms
51,288 KB
testcase_25 AC 133 ms
52,304 KB
testcase_26 AC 148 ms
54,420 KB
testcase_27 AC 139 ms
54,512 KB
testcase_28 AC 126 ms
54,556 KB
testcase_29 AC 118 ms
54,552 KB
testcase_30 AC 138 ms
54,368 KB
testcase_31 AC 144 ms
54,564 KB
testcase_32 AC 170 ms
54,676 KB
testcase_33 AC 50 ms
50,316 KB
testcase_34 AC 49 ms
50,132 KB
testcase_35 AC 51 ms
50,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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");
		}
	}
}
0