結果
問題 |
No.1071 ベホマラー
|
ユーザー |
![]() |
提出日時 | 2020-08-20 06:59:38 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 604 bytes |
コンパイル時間 | 2,944 ms |
コンパイル使用メモリ | 75,372 KB |
実行使用メモリ | 52,392 KB |
最終ジャッジ日時 | 2024-10-12 22:15:34 |
合計ジャッジ時間 | 16,298 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 8 WA * 12 |
ソースコード
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); } }