結果

問題 No.1416 ショッピングモール
ユーザー harurunharurun
提出日時 2020-12-17 13:07:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 404 ms / 1,000 ms
コード長 588 bytes
コンパイル時間 5,165 ms
コンパイル使用メモリ 82,888 KB
実行使用メモリ 62,336 KB
最終ジャッジ日時 2023-10-20 11:26:20
合計ジャッジ時間 10,353 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
57,264 KB
testcase_01 AC 126 ms
57,352 KB
testcase_02 AC 128 ms
57,556 KB
testcase_03 AC 135 ms
57,312 KB
testcase_04 AC 129 ms
57,516 KB
testcase_05 AC 164 ms
57,608 KB
testcase_06 AC 137 ms
57,304 KB
testcase_07 AC 168 ms
57,508 KB
testcase_08 AC 180 ms
57,576 KB
testcase_09 AC 134 ms
57,368 KB
testcase_10 AC 118 ms
56,108 KB
testcase_11 AC 196 ms
59,836 KB
testcase_12 AC 163 ms
57,476 KB
testcase_13 AC 195 ms
59,880 KB
testcase_14 AC 205 ms
58,176 KB
testcase_15 AC 225 ms
60,760 KB
testcase_16 AC 195 ms
60,204 KB
testcase_17 AC 233 ms
59,056 KB
testcase_18 AC 230 ms
60,612 KB
testcase_19 AC 240 ms
61,272 KB
testcase_20 AC 232 ms
60,812 KB
testcase_21 AC 387 ms
60,044 KB
testcase_22 AC 404 ms
62,256 KB
testcase_23 AC 349 ms
62,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int n,ans=0,cnt=0,N,a=1;
    n=Integer.parseInt(scan.next());
    N=n;
    Integer[] A=new Integer[n];
    for(int i=0;i<n;i++)A[i]=Integer.parseInt(scan.next());
    Arrays.sort(A,Collections.reverseOrder());
    for(int i=0;i<17;i++){
      a=Math.min(a,N);
      for(int j=0;j<a;j++){
        ans+=i*A[cnt++];
      }
      N-=a;
      a*=2;
      if(N<=0)break;
    }
    System.out.println(ans);
  }
}

0