結果

問題 No.1736 Princess vs. Dragoness
ユーザー CuriousFairy315CuriousFairy315
提出日時 2021-11-12 22:03:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 856 bytes
コンパイル時間 2,028 ms
コンパイル使用メモリ 79,408 KB
実行使用メモリ 47,704 KB
最終ジャッジ日時 2024-05-04 08:47:01
合計ジャッジ時間 10,431 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
41,236 KB
testcase_01 AC 110 ms
41,392 KB
testcase_02 AC 111 ms
41,344 KB
testcase_03 AC 196 ms
43,592 KB
testcase_04 AC 214 ms
45,064 KB
testcase_05 AC 154 ms
42,140 KB
testcase_06 AC 250 ms
46,148 KB
testcase_07 AC 263 ms
46,108 KB
testcase_08 AC 247 ms
45,780 KB
testcase_09 AC 250 ms
46,200 KB
testcase_10 AC 144 ms
40,940 KB
testcase_11 AC 281 ms
46,356 KB
testcase_12 AC 228 ms
45,276 KB
testcase_13 AC 254 ms
45,844 KB
testcase_14 AC 252 ms
47,084 KB
testcase_15 AC 229 ms
44,328 KB
testcase_16 AC 206 ms
43,688 KB
testcase_17 AC 238 ms
46,116 KB
testcase_18 AC 236 ms
46,176 KB
testcase_19 AC 236 ms
46,108 KB
testcase_20 AC 190 ms
43,112 KB
testcase_21 AC 253 ms
46,160 KB
testcase_22 AC 255 ms
46,072 KB
testcase_23 AC 234 ms
46,716 KB
testcase_24 AC 147 ms
42,124 KB
testcase_25 AC 221 ms
44,560 KB
testcase_26 AC 230 ms
46,268 KB
testcase_27 AC 274 ms
47,704 KB
testcase_28 AC 226 ms
47,364 KB
testcase_29 AC 207 ms
45,804 KB
testcase_30 AC 235 ms
46,180 KB
testcase_31 AC 238 ms
45,004 KB
testcase_32 AC 237 ms
46,056 KB
testcase_33 AC 111 ms
41,448 KB
testcase_34 AC 99 ms
41,568 KB
testcase_35 AC 100 ms
40,204 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