結果
| 問題 | No.1416 ショッピングモール |
| コンテスト | |
| ユーザー |
ks2m
|
| 提出日時 | 2021-03-05 22:20:38 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 267 ms / 1,000 ms |
| コード長 | 524 bytes |
| 記録 | |
| コンパイル時間 | 3,590 ms |
| コンパイル使用メモリ | 82,496 KB |
| 実行使用メモリ | 56,140 KB |
| 最終ジャッジ日時 | 2026-04-23 18:42:44 |
| 合計ジャッジ時間 | 7,168 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
sc.close();
Arrays.sort(a);
int f = 0;
int m = 1;
int c = 0;
int ans = 0;
for (int i = n - 1; i >= 0; i--) {
if (c == m) {
f++;
m = 1 << f;
c = 0;
}
ans += a[i] * f;
c++;
}
System.out.println(ans);
}
}
ks2m