結果

問題 No.1071 ベホマラー
ユーザー tentententen
提出日時 2020-08-20 07:00:52
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 610 bytes
コンパイル時間 2,397 ms
コンパイル使用メモリ 74,820 KB
実行使用メモリ 61,616 KB
最終ジャッジ日時 2024-04-20 23:58:14
合計ジャッジ時間 14,661 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
39,904 KB
testcase_01 AC 132 ms
41,088 KB
testcase_02 AC 130 ms
41,188 KB
testcase_03 AC 131 ms
40,912 KB
testcase_04 AC 133 ms
41,272 KB
testcase_05 AC 129 ms
41,460 KB
testcase_06 AC 137 ms
41,216 KB
testcase_07 AC 142 ms
41,056 KB
testcase_08 AC 146 ms
41,552 KB
testcase_09 AC 120 ms
39,876 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 538 ms
47,636 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 604 ms
50,336 KB
testcase_18 AC 672 ms
48,508 KB
testcase_19 AC 609 ms
51,352 KB
testcase_20 AC 583 ms
49,808 KB
testcase_21 WA -
testcase_22 AC 647 ms
49,436 KB
testcase_23 AC 610 ms
49,984 KB
testcase_24 AC 648 ms
48,412 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();
		long x = sc.nextInt();
		long y = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = (sc.nextInt() - 1 + k - 1) / k;
		}
		Arrays.sort(arr);
		long sum = arr[n - 1];
		long min = arr[n - 1] * y;
		for (int i = n - 2; i >= 0; i--) {
		    min = Math.min(min, arr[i] * y + (sum - (long)(n - i - 1) * arr[i]) * x);
		    sum += arr[i];
		}
		min = Math.min(min, sum * x);
		System.out.println(min);
	}
}
0