結果

問題 No.1071 ベホマラー
ユーザー tentententen
提出日時 2020-08-20 06:59:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 604 bytes
コンパイル時間 2,748 ms
コンパイル使用メモリ 75,112 KB
実行使用メモリ 61,372 KB
最終ジャッジ日時 2024-04-20 23:57:00
合計ジャッジ時間 13,951 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
40,904 KB
testcase_01 AC 109 ms
48,104 KB
testcase_02 AC 114 ms
41,356 KB
testcase_03 AC 109 ms
41,388 KB
testcase_04 AC 112 ms
41,384 KB
testcase_05 AC 112 ms
41,404 KB
testcase_06 AC 114 ms
41,200 KB
testcase_07 AC 120 ms
41,420 KB
testcase_08 AC 118 ms
41,596 KB
testcase_09 AC 98 ms
40,340 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 575 ms
49,652 KB
testcase_21 WA -
testcase_22 AC 572 ms
49,668 KB
testcase_23 AC 499 ms
49,644 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

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 - (n - i - 1) * arr[i]) * x);
		    sum += arr[i];
		}
		min = Math.min(min, sum * x);
		System.out.println(min);
	}
}
0