結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー CuriousFairy315CuriousFairy315
提出日時 2021-11-12 22:11:25
言語 Java19
(openjdk 21)
結果
AC  
実行時間 1,374 ms / 3,000 ms
コード長 850 bytes
コンパイル時間 2,728 ms
コンパイル使用メモリ 73,900 KB
実行使用メモリ 65,564 KB
最終ジャッジ日時 2023-08-17 01:52:16
合計ジャッジ時間 35,898 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,332 KB
testcase_01 AC 122 ms
55,548 KB
testcase_02 AC 122 ms
55,640 KB
testcase_03 AC 121 ms
55,756 KB
testcase_04 AC 1,223 ms
64,992 KB
testcase_05 AC 1,335 ms
65,164 KB
testcase_06 AC 765 ms
64,916 KB
testcase_07 AC 120 ms
55,624 KB
testcase_08 AC 975 ms
62,260 KB
testcase_09 AC 1,126 ms
62,236 KB
testcase_10 AC 720 ms
61,812 KB
testcase_11 AC 706 ms
61,456 KB
testcase_12 AC 301 ms
60,480 KB
testcase_13 AC 1,038 ms
62,468 KB
testcase_14 AC 1,095 ms
62,796 KB
testcase_15 AC 1,285 ms
64,760 KB
testcase_16 AC 654 ms
61,620 KB
testcase_17 AC 845 ms
61,860 KB
testcase_18 AC 830 ms
61,820 KB
testcase_19 AC 594 ms
60,772 KB
testcase_20 AC 562 ms
61,604 KB
testcase_21 AC 1,075 ms
62,288 KB
testcase_22 AC 1,210 ms
65,132 KB
testcase_23 AC 1,374 ms
65,052 KB
testcase_24 AC 1,314 ms
63,176 KB
testcase_25 AC 1,237 ms
64,828 KB
testcase_26 AC 1,287 ms
64,812 KB
testcase_27 AC 1,305 ms
65,016 KB
testcase_28 AC 1,231 ms
65,156 KB
testcase_29 AC 1,277 ms
65,464 KB
testcase_30 AC 1,207 ms
65,104 KB
testcase_31 AC 1,333 ms
64,900 KB
testcase_32 AC 1,257 ms
65,564 KB
testcase_33 AC 132 ms
56,056 KB
testcase_34 AC 123 ms
55,992 KB
testcase_35 AC 133 ms
55,812 KB
testcase_36 AC 130 ms
55,900 KB
testcase_37 AC 128 ms
55,904 KB
testcase_38 AC 190 ms
56,588 KB
testcase_39 AC 202 ms
55,016 KB
testcase_40 AC 156 ms
55,776 KB
testcase_41 AC 188 ms
56,952 KB
testcase_42 AC 163 ms
55,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
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;
				int[] h = H.clone();
				int count = A;
				for (int i = 0;i < N;++ i) {
					h[i] = Math.max(0, h[i] - mid);
					int a = Math.min(count, h[i] / X);
					h[i] -= a * X;
					count -= a;
				}
				Arrays.sort(h);
				for (int i = 0;i < Math.min(N, count);++ i) h[N - i - 1] = 0;
				long sum = 0;
				for (int i : h) sum += i;
				if ((long)B * Y >= sum) ok = mid;
				else ng = mid;
			}
			System.out.println(ok);
		}
	}
}
0