結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー tentententen
提出日時 2021-11-15 09:29:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,274 ms / 3,000 ms
コード長 2,045 bytes
コンパイル時間 2,094 ms
コンパイル使用メモリ 74,676 KB
実行使用メモリ 68,500 KB
最終ジャッジ日時 2023-08-20 23:22:32
合計ジャッジ時間 43,390 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,568 KB
testcase_01 AC 43 ms
49,936 KB
testcase_02 AC 44 ms
49,528 KB
testcase_03 AC 42 ms
49,944 KB
testcase_04 AC 1,548 ms
66,592 KB
testcase_05 AC 2,272 ms
67,084 KB
testcase_06 AC 377 ms
63,144 KB
testcase_07 AC 42 ms
49,648 KB
testcase_08 AC 784 ms
58,480 KB
testcase_09 AC 868 ms
57,428 KB
testcase_10 AC 1,013 ms
60,424 KB
testcase_11 AC 641 ms
58,752 KB
testcase_12 AC 122 ms
53,272 KB
testcase_13 AC 1,177 ms
63,984 KB
testcase_14 AC 1,526 ms
64,440 KB
testcase_15 AC 1,474 ms
66,664 KB
testcase_16 AC 1,182 ms
59,864 KB
testcase_17 AC 912 ms
62,376 KB
testcase_18 AC 1,214 ms
59,552 KB
testcase_19 AC 390 ms
58,732 KB
testcase_20 AC 467 ms
59,780 KB
testcase_21 AC 681 ms
59,676 KB
testcase_22 AC 1,251 ms
61,548 KB
testcase_23 AC 1,435 ms
67,768 KB
testcase_24 AC 2,274 ms
68,436 KB
testcase_25 AC 1,871 ms
65,180 KB
testcase_26 AC 1,513 ms
67,736 KB
testcase_27 AC 2,129 ms
67,716 KB
testcase_28 AC 1,615 ms
67,188 KB
testcase_29 AC 2,228 ms
67,420 KB
testcase_30 AC 1,676 ms
68,140 KB
testcase_31 AC 1,839 ms
68,500 KB
testcase_32 AC 2,202 ms
68,392 KB
testcase_33 AC 54 ms
50,744 KB
testcase_34 AC 42 ms
49,576 KB
testcase_35 AC 53 ms
49,844 KB
testcase_36 AC 53 ms
49,764 KB
testcase_37 AC 44 ms
49,820 KB
testcase_38 AC 76 ms
51,532 KB
testcase_39 AC 92 ms
52,148 KB
testcase_40 AC 73 ms
51,832 KB
testcase_41 AC 68 ms
51,548 KB
testcase_42 AC 54 ms
50,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        long y = sc.nextInt();
        int[] helths = new int[n];
        for (int i = 0; i < n; i++) {
            helths[i] = sc.nextInt();
        }
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        int left = -1;
        int right = 1000000000;
        while (right - left > 1) {
            int m = (left + right) / 2;
            for (int i = 0; i < n; i++) {
                if (helths[i] - m > 0) {
                    queue.add(m - helths[i]);
                }
            }
            for (int i = 0; i < a && queue.size() > 0; i++) {
                int z = -queue.poll();
                if (z > x) {
                    queue.add(x - z);
                }
            }
            long sum = 0;
            while (queue.size() > 0) {
                sum -= queue.poll();
            }
            if (sum <= b * y) {
                right = m;
            } else {
                left = m;
            }
        }
        System.out.println(right);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0