結果

問題 No.1071 ベホマラー
ユーザー htensaihtensai
提出日時 2020-06-10 08:29:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 703 ms / 2,000 ms
コード長 691 bytes
コンパイル時間 2,123 ms
コンパイル使用メモリ 72,188 KB
実行使用メモリ 67,232 KB
最終ジャッジ日時 2023-09-03 19:45:23
合計ジャッジ時間 17,862 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,644 KB
testcase_01 AC 116 ms
55,932 KB
testcase_02 AC 110 ms
55,868 KB
testcase_03 AC 110 ms
56,024 KB
testcase_04 AC 112 ms
55,760 KB
testcase_05 AC 110 ms
55,764 KB
testcase_06 AC 119 ms
56,272 KB
testcase_07 AC 120 ms
56,148 KB
testcase_08 AC 120 ms
55,564 KB
testcase_09 AC 110 ms
55,936 KB
testcase_10 AC 604 ms
64,092 KB
testcase_11 AC 586 ms
62,748 KB
testcase_12 AC 518 ms
61,492 KB
testcase_13 AC 550 ms
62,848 KB
testcase_14 AC 553 ms
65,176 KB
testcase_15 AC 703 ms
67,100 KB
testcase_16 AC 699 ms
66,912 KB
testcase_17 AC 698 ms
66,892 KB
testcase_18 AC 677 ms
67,232 KB
testcase_19 AC 695 ms
66,900 KB
testcase_20 AC 553 ms
64,468 KB
testcase_21 AC 562 ms
64,696 KB
testcase_22 AC 544 ms
64,112 KB
testcase_23 AC 545 ms
64,756 KB
testcase_24 AC 651 ms
63,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		PriorityQueue<Integer> queue = new PriorityQueue<>();
		for (int i = 0; i < n; i++) {
		    queue.add(sc.nextInt());
		}
		int base = 1;
		long total = 0;
		while (queue.size() > 0) {
		    int z = queue.peek();
		    int count = (z - base + k - 1) / k;
		    if (queue.size() > y / x) {
		        base += count * k;
		        total += (long)count * y;
		    } else {
		        total += (long)count * x;
		    }
		    queue.poll();
		}
		System.out.println(total);
	}
}
0