結果

問題 No.1416 ショッピングモール
ユーザー ks2mks2m
提出日時 2021-03-05 22:20:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 466 ms / 1,000 ms
コード長 524 bytes
コンパイル時間 3,248 ms
コンパイル使用メモリ 75,492 KB
実行使用メモリ 49,324 KB
最終ジャッジ日時 2024-04-16 10:05:56
合計ジャッジ時間 9,172 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,220 KB
testcase_01 AC 131 ms
41,388 KB
testcase_02 AC 130 ms
41,564 KB
testcase_03 AC 136 ms
41,584 KB
testcase_04 AC 125 ms
41,128 KB
testcase_05 AC 175 ms
42,248 KB
testcase_06 AC 132 ms
41,304 KB
testcase_07 AC 177 ms
42,408 KB
testcase_08 AC 185 ms
42,628 KB
testcase_09 AC 134 ms
41,456 KB
testcase_10 AC 126 ms
41,828 KB
testcase_11 AC 206 ms
44,764 KB
testcase_12 AC 175 ms
42,116 KB
testcase_13 AC 212 ms
44,804 KB
testcase_14 AC 216 ms
46,472 KB
testcase_15 AC 244 ms
46,804 KB
testcase_16 AC 216 ms
46,104 KB
testcase_17 AC 242 ms
47,504 KB
testcase_18 AC 243 ms
47,324 KB
testcase_19 AC 247 ms
47,776 KB
testcase_20 AC 247 ms
47,324 KB
testcase_21 AC 452 ms
48,164 KB
testcase_22 AC 466 ms
49,324 KB
testcase_23 AC 409 ms
47,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
	}
}
0