結果

問題 No.1416 ショッピングモール
ユーザー 👑 CleyL
提出日時 2022-05-13 00:21:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 35 ms / 1,000 ms
コード長 432 bytes
コンパイル時間 823 ms
コンパイル使用メモリ 78,652 KB
最終ジャッジ日時 2025-01-29 06:21:08
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  vector<long long> A(n);
  for(int i = 0; n > i; i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end(),greater<long long>());
  long long nw = 2;
  long long place = 0;
  long long ans = 0;
  for(int i = 0; n > i; i++){
    ans += A[i]*place;
    if(i+2 == nw){
      nw *= 2;
      place++;
    }
  }
  cout << ans << endl;

}
0