結果
| 問題 |
No.1416 ショッピングモール
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-03-06 14:15:22 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 471 ms / 1,000 ms |
| コード長 | 587 bytes |
| コンパイル時間 | 4,326 ms |
| コンパイル使用メモリ | 74,744 KB |
| 実行使用メモリ | 59,492 KB |
| 最終ジャッジ日時 | 2024-10-08 13:00:12 |
| 合計ジャッジ時間 | 9,621 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] counts = new int[n];
for (int i = 0; i < n; i++) {
counts[i] = sc.nextInt();
}
Arrays.sort(counts);
int idx = n - 1;
long ans = 0;
for (int i = 0; idx >= 0; i++) {
for (int j = 0; j < (1 << i) && idx >= 0; j++) {
ans += counts[idx] * i;
idx--;
}
}
System.out.println(ans);
}
}
tenten