結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー ks2mks2m
提出日時 2021-11-12 21:28:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,133 ms / 3,000 ms
コード長 1,175 bytes
コンパイル時間 2,778 ms
コンパイル使用メモリ 75,904 KB
実行使用メモリ 71,116 KB
最終ジャッジ日時 2023-08-16 21:34:47
合計ジャッジ時間 44,762 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,540 KB
testcase_01 AC 43 ms
49,488 KB
testcase_02 AC 45 ms
49,432 KB
testcase_03 AC 157 ms
54,984 KB
testcase_04 AC 1,626 ms
68,252 KB
testcase_05 AC 2,021 ms
70,544 KB
testcase_06 AC 1,272 ms
69,816 KB
testcase_07 AC 169 ms
55,020 KB
testcase_08 AC 449 ms
64,320 KB
testcase_09 AC 562 ms
66,600 KB
testcase_10 AC 1,043 ms
63,656 KB
testcase_11 AC 840 ms
60,180 KB
testcase_12 AC 178 ms
56,264 KB
testcase_13 AC 1,188 ms
68,468 KB
testcase_14 AC 1,238 ms
68,636 KB
testcase_15 AC 1,265 ms
69,728 KB
testcase_16 AC 1,187 ms
66,144 KB
testcase_17 AC 888 ms
66,764 KB
testcase_18 AC 1,238 ms
67,764 KB
testcase_19 AC 619 ms
62,276 KB
testcase_20 AC 441 ms
59,680 KB
testcase_21 AC 771 ms
68,328 KB
testcase_22 AC 1,250 ms
69,612 KB
testcase_23 AC 1,757 ms
68,944 KB
testcase_24 AC 2,133 ms
69,964 KB
testcase_25 AC 1,773 ms
70,104 KB
testcase_26 AC 1,841 ms
71,116 KB
testcase_27 AC 1,793 ms
67,624 KB
testcase_28 AC 1,813 ms
70,808 KB
testcase_29 AC 1,925 ms
70,928 KB
testcase_30 AC 1,795 ms
69,748 KB
testcase_31 AC 1,806 ms
71,016 KB
testcase_32 AC 1,885 ms
69,404 KB
testcase_33 AC 61 ms
51,532 KB
testcase_34 AC 75 ms
51,920 KB
testcase_35 AC 86 ms
51,524 KB
testcase_36 AC 89 ms
51,560 KB
testcase_37 AC 74 ms
51,200 KB
testcase_38 AC 81 ms
52,028 KB
testcase_39 AC 99 ms
52,628 KB
testcase_40 AC 75 ms
52,064 KB
testcase_41 AC 88 ms
52,168 KB
testcase_42 AC 73 ms
52,156 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;
			}
		}
		System.out.println(ok);
	}
}
0