結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー CuriousFairy315
提出日時 2021-11-12 22:10:10
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 837 bytes
コンパイル時間 2,616 ms
コンパイル使用メモリ 77,972 KB
実行使用メモリ 69,636 KB
最終ジャッジ日時 2024-11-25 18:58:55
合計ジャッジ時間 31,287 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 RE * 10
権限があれば一括ダウンロードができます

ソースコード

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 < 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