結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー tentententen
提出日時 2023-07-19 12:48:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,696 ms / 3,000 ms
コード長 2,575 bytes
コンパイル時間 2,818 ms
コンパイル使用メモリ 95,132 KB
実行使用メモリ 71,512 KB
最終ジャッジ日時 2023-10-19 15:16:26
合計ジャッジ時間 35,672 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
53,704 KB
testcase_01 AC 55 ms
53,760 KB
testcase_02 AC 57 ms
53,756 KB
testcase_03 AC 55 ms
53,756 KB
testcase_04 AC 1,235 ms
69,548 KB
testcase_05 AC 1,696 ms
71,512 KB
testcase_06 AC 502 ms
67,680 KB
testcase_07 AC 57 ms
53,760 KB
testcase_08 AC 367 ms
62,308 KB
testcase_09 AC 412 ms
64,348 KB
testcase_10 AC 879 ms
63,132 KB
testcase_11 AC 627 ms
62,872 KB
testcase_12 AC 127 ms
55,900 KB
testcase_13 AC 981 ms
66,244 KB
testcase_14 AC 977 ms
68,056 KB
testcase_15 AC 917 ms
69,244 KB
testcase_16 AC 1,058 ms
62,560 KB
testcase_17 AC 664 ms
64,600 KB
testcase_18 AC 968 ms
63,496 KB
testcase_19 AC 352 ms
60,632 KB
testcase_20 AC 297 ms
60,652 KB
testcase_21 AC 549 ms
61,992 KB
testcase_22 AC 954 ms
69,560 KB
testcase_23 AC 1,422 ms
69,844 KB
testcase_24 AC 1,583 ms
70,824 KB
testcase_25 AC 1,436 ms
68,380 KB
testcase_26 AC 1,427 ms
69,996 KB
testcase_27 AC 1,458 ms
70,168 KB
testcase_28 AC 1,507 ms
69,872 KB
testcase_29 AC 1,559 ms
70,176 KB
testcase_30 AC 1,405 ms
69,516 KB
testcase_31 AC 1,569 ms
70,128 KB
testcase_32 AC 1,649 ms
71,028 KB
testcase_33 AC 62 ms
53,780 KB
testcase_34 AC 57 ms
52,668 KB
testcase_35 AC 69 ms
53,784 KB
testcase_36 AC 72 ms
53,776 KB
testcase_37 AC 57 ms
53,728 KB
testcase_38 AC 87 ms
54,368 KB
testcase_39 AC 100 ms
55,204 KB
testcase_40 AC 66 ms
53,792 KB
testcase_41 AC 88 ms
54,980 KB
testcase_42 AC 68 ms
54,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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();
        int y = sc.nextInt();
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
        }
        long max = (long)b * y;
        int left = -1;
        int right = Integer.MAX_VALUE / 2;
        while (right - left > 1) {
            int m = (left + right) / 2;
            PriorityQueue<Integer> queue = new PriorityQueue<>();
            long total = 0;
            for (int z : values) {
                if (z > m) {
                    queue.add(m - z);
                    total += z - m;
                }
            }
            for (int i = 0; i < a && queue.size() > 0; i++) {
                if (queue.peek() + x >= 0) {
                    total += queue.poll();
                } else {
                    queue.add(queue.poll() + x);
                    total -= x;
                }
            }
            if (total <= max) {
                right = m;
            } else {
                left = m;
            }
        }
        System.out.println(right);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0