結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー CuriousFairy315CuriousFairy315
提出日時 2021-11-12 22:02:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,952 ms / 3,000 ms
コード長 836 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 79,908 KB
実行使用メモリ 69,280 KB
最終ジャッジ日時 2024-05-04 08:45:46
合計ジャッジ時間 56,761 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
41,160 KB
testcase_01 AC 120 ms
41,492 KB
testcase_02 AC 123 ms
41,272 KB
testcase_03 AC 168 ms
46,060 KB
testcase_04 AC 2,351 ms
67,800 KB
testcase_05 AC 2,952 ms
67,576 KB
testcase_06 AC 1,424 ms
67,460 KB
testcase_07 AC 169 ms
46,240 KB
testcase_08 AC 1,217 ms
61,580 KB
testcase_09 AC 1,485 ms
67,012 KB
testcase_10 AC 1,113 ms
53,924 KB
testcase_11 AC 928 ms
50,164 KB
testcase_12 AC 313 ms
47,916 KB
testcase_13 AC 1,470 ms
65,828 KB
testcase_14 AC 2,016 ms
66,908 KB
testcase_15 AC 2,093 ms
67,136 KB
testcase_16 AC 1,372 ms
50,092 KB
testcase_17 AC 1,351 ms
55,464 KB
testcase_18 AC 1,404 ms
58,832 KB
testcase_19 AC 778 ms
54,568 KB
testcase_20 AC 772 ms
51,784 KB
testcase_21 AC 1,347 ms
66,808 KB
testcase_22 AC 1,935 ms
67,428 KB
testcase_23 AC 2,113 ms
69,280 KB
testcase_24 AC 2,836 ms
67,896 KB
testcase_25 AC 2,426 ms
68,052 KB
testcase_26 AC 2,167 ms
69,000 KB
testcase_27 AC 2,570 ms
68,080 KB
testcase_28 AC 2,342 ms
66,596 KB
testcase_29 AC 2,516 ms
68,040 KB
testcase_30 AC 2,478 ms
67,792 KB
testcase_31 AC 2,290 ms
67,932 KB
testcase_32 AC 2,761 ms
68,252 KB
testcase_33 AC 143 ms
41,812 KB
testcase_34 AC 139 ms
41,220 KB
testcase_35 AC 166 ms
41,964 KB
testcase_36 AC 152 ms
42,200 KB
testcase_37 AC 152 ms
42,016 KB
testcase_38 AC 191 ms
42,660 KB
testcase_39 AC 207 ms
44,004 KB
testcase_40 AC 174 ms
42,156 KB
testcase_41 AC 197 ms
42,480 KB
testcase_42 AC 156 ms
41,712 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