結果

問題 No.1416 ショッピングモール
ユーザー ocvret_ocvret_
提出日時 2021-03-05 21:29:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 1,000 ms
コード長 689 bytes
コンパイル時間 1,723 ms
コンパイル使用メモリ 168,552 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 08:49:42
合計ジャッジ時間 2,615 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
// #include<atcoder/all>
// #include<boost/multiprecision/cpp_int.hpp>

using namespace std;
// using namespace atcoder;
// using bint = boost::multiprecision::cpp_int;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  sort(ALL(a),greater<ll>());
  ll k = 1,l = 1,m = 0;
  ll res = 0;
  rep(i,n){
    if(l)res += m*a[i],l--;
    else {
      k <<= 1;
      l = k-1;
      m++;
      res += m*a[i];
    }
  }
  cout << res << "\n";
  

  return 0;
}
0