結果
問題 | No.1416 ショッピングモール |
ユーザー |
![]() |
提出日時 | 2021-03-05 21:27:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 1,000 ms |
コード長 | 575 bytes |
コンパイル時間 | 1,751 ms |
コンパイル使用メモリ | 200,792 KB |
最終ジャッジ日時 | 2025-01-19 10:37:25 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++) void solve() { ll n; cin >> n; vector<ll> a(n); rep(i, 0, n) cin >> a[i]; sort(a.rbegin(), a.rend()); ll ans = 0, ptr = 0; rep(i, 0, n) { if(ptr == n) break; rep(j, 0, 1LL<<i) { ans += a[ptr++] * i; if(ptr == n) break; } } cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }