結果

問題 No.1416 ショッピングモール
ユーザー KKT89
提出日時 2021-03-05 21:38:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 568 bytes
コンパイル時間 2,846 ms
コンパイル使用メモリ 199,860 KB
最終ジャッジ日時 2025-01-19 10:44:55
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

constexpr ll mod=1e9+7;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	ll res=0;
	int f=0;
	int cnt=0;
	for(int i=0;i<n;i++){
		res+=a[i]*f;
		cnt++;
		if(cnt==(1LL<<f)){
			f++;
			cnt=0;
		}
	}
	printf("%lld\n",res);
}
0