結果

問題 No.1416 ショッピングモール
ユーザー harurunharurun
提出日時 2020-12-17 12:41:37
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 11 ms / 1,000 ms
コード長 523 bytes
コンパイル時間 791 ms
コンパイル使用メモリ 30,140 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 11:25:36
合計ジャッジ時間 1,748 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,348 KB
testcase_01 AC 3 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 4 ms
4,348 KB
testcase_18 AC 4 ms
4,348 KB
testcase_19 AC 4 ms
4,348 KB
testcase_20 AC 4 ms
4,348 KB
testcase_21 AC 11 ms
4,348 KB
testcase_22 AC 11 ms
4,348 KB
testcase_23 AC 8 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int cmp(const void* a,const void* b){
  return *(int*)b-*(int*)a;
}

int min(int a,int b){
  if(a<b)return a;
  return b;
}

int main(){
  int n,ans=0,cnt=0,N,a=1,A[50001];
  scanf("%d",&n);
  N=n;
  for(int i=0;i<50001;i++)A[i]=0;
  for(int i=0;i<n;i++)scanf("%d",&A[i]);
  qsort(A,50001,sizeof(int),cmp);
  for(int i=0;i<17;i++){
    a=min(a,N);
    for(int j=0;j<a;j++){
      ans+=i*A[cnt++];
    }
    N-=a;
    a*=2;
    if(N<=0)break;
  }

  printf("%d\n",ans);
  return 0;
}
0