結果
問題 | No.1071 ベホマラー |
ユーザー | ks2m |
提出日時 | 2020-06-05 21:48:44 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,057 ms / 2,000 ms |
コード長 | 1,076 bytes |
コンパイル時間 | 2,571 ms |
コンパイル使用メモリ | 79,100 KB |
実行使用メモリ | 64,252 KB |
最終ジャッジ日時 | 2024-05-09 20:46:42 |
合計ジャッジ時間 | 17,570 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 126 ms
41,620 KB |
testcase_01 | AC | 129 ms
41,484 KB |
testcase_02 | AC | 127 ms
41,712 KB |
testcase_03 | AC | 128 ms
41,676 KB |
testcase_04 | AC | 131 ms
41,692 KB |
testcase_05 | AC | 135 ms
41,692 KB |
testcase_06 | AC | 137 ms
41,740 KB |
testcase_07 | AC | 149 ms
41,700 KB |
testcase_08 | AC | 145 ms
41,644 KB |
testcase_09 | AC | 127 ms
41,428 KB |
testcase_10 | AC | 850 ms
62,660 KB |
testcase_11 | AC | 930 ms
62,828 KB |
testcase_12 | AC | 745 ms
51,472 KB |
testcase_13 | AC | 875 ms
57,200 KB |
testcase_14 | AC | 946 ms
63,096 KB |
testcase_15 | AC | 1,022 ms
63,420 KB |
testcase_16 | AC | 1,053 ms
63,764 KB |
testcase_17 | AC | 1,036 ms
63,868 KB |
testcase_18 | AC | 1,052 ms
62,640 KB |
testcase_19 | AC | 1,057 ms
64,004 KB |
testcase_20 | AC | 637 ms
48,972 KB |
testcase_21 | AC | 650 ms
50,152 KB |
testcase_22 | AC | 647 ms
49,568 KB |
testcase_23 | AC | 568 ms
48,420 KB |
testcase_24 | AC | 921 ms
64,252 KB |
ソースコード
import java.math.BigInteger; import java.util.Scanner; import java.util.TreeMap; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); BigInteger x = sc.nextBigInteger(); BigInteger y = sc.nextBigInteger(); TreeMap<Integer, Integer> map = new TreeMap<>(); long sum = 0; for (int i = 0; i < n; i++) { int a = sc.nextInt(); int b = (a + k - 2) / k; if (map.containsKey(b)) { map.put(b, map.get(b) + 1); } else { map.put(b, 1); } sum += b; } sc.close(); BigInteger ans = BigInteger.valueOf(sum).multiply(x); BigInteger val = ans; int pre = 0; int rem = n; for (int key : map.keySet()) { BigInteger d = BigInteger.valueOf(key - pre); BigInteger add = d.multiply(y); BigInteger sub = d.multiply(x).multiply(BigInteger.valueOf(rem)); pre = key; rem -= map.get(key); val = val.add(add).subtract(sub); if (val.compareTo(ans) < 0) { ans = val; } } System.out.println(ans.toString()); } }