結果

問題 No.1736 Princess vs. Dragoness
ユーザー CuriousFairy315CuriousFairy315
提出日時 2021-11-12 22:03:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 375 ms / 2,000 ms
コード長 856 bytes
コンパイル時間 2,593 ms
コンパイル使用メモリ 76,000 KB
実行使用メモリ 60,836 KB
最終ジャッジ日時 2023-08-17 01:33:38
合計ジャッジ時間 14,022 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
55,848 KB
testcase_01 AC 143 ms
55,784 KB
testcase_02 AC 144 ms
55,744 KB
testcase_03 AC 254 ms
58,520 KB
testcase_04 AC 300 ms
58,772 KB
testcase_05 AC 211 ms
55,784 KB
testcase_06 AC 334 ms
59,044 KB
testcase_07 AC 340 ms
58,596 KB
testcase_08 AC 287 ms
59,200 KB
testcase_09 AC 320 ms
59,028 KB
testcase_10 AC 187 ms
55,836 KB
testcase_11 AC 375 ms
60,436 KB
testcase_12 AC 295 ms
59,096 KB
testcase_13 AC 325 ms
60,836 KB
testcase_14 AC 324 ms
59,232 KB
testcase_15 AC 273 ms
60,508 KB
testcase_16 AC 278 ms
58,756 KB
testcase_17 AC 311 ms
59,048 KB
testcase_18 AC 307 ms
59,312 KB
testcase_19 AC 305 ms
59,204 KB
testcase_20 AC 253 ms
58,644 KB
testcase_21 AC 304 ms
58,840 KB
testcase_22 AC 324 ms
59,476 KB
testcase_23 AC 276 ms
59,708 KB
testcase_24 AC 212 ms
55,740 KB
testcase_25 AC 268 ms
58,736 KB
testcase_26 AC 282 ms
59,176 KB
testcase_27 AC 332 ms
59,988 KB
testcase_28 AC 278 ms
59,192 KB
testcase_29 AC 273 ms
59,204 KB
testcase_30 AC 301 ms
59,284 KB
testcase_31 AC 285 ms
59,176 KB
testcase_32 AC 297 ms
59,140 KB
testcase_33 AC 140 ms
55,320 KB
testcase_34 AC 138 ms
55,532 KB
testcase_35 AC 138 ms
55,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt(), X = sc.nextInt(), Y = sc.nextInt();
			int[] H = new int[N];
			for (int i = 0;i < N;++ i) H[i] = sc.nextInt();
			int ng = -1, ok = 1_000_000_000;
			while(ok - ng > 1) {
				int mid = ok + ng >> 1;
				PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());
				for (int i : H) pq.add(i - mid);
				for (int i = 0;i < A;++ i) pq.add(pq.poll() - X);
				long sum = 0;
				while(!pq.isEmpty()) {
					if (pq.peek() > 0) sum += pq.poll();
					else break;
				}
				if ((long)B * Y >= sum) ok = mid;
				else ng = mid;
			}
			System.out.println(ok == 0 ? "Yes" : "No");
		}
	}
}
0