結果
問題 | No.1416 ショッピングモール |
ユーザー |
|
提出日時 | 2021-03-05 22:55:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 1,000 ms |
コード長 | 634 bytes |
コンパイル時間 | 2,731 ms |
コンパイル使用メモリ | 155,452 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 04:11:57 |
合計ジャッジ時間 | 3,652 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <iostream>#include <string>#include <vector>#include <algorithm>#include <utility>#include <map>#include <set>#include <queue>#include <iomanip>#include <cstring>#include <atcoder/all>using namespace std;using namespace atcoder;typedef long long ll;#define rep(i,n) for (int i = 0; i < int(n);i++)const ll INF = 1e9;int main(){int n;cin >> n;vector<ll> v(n);rep(i,n) cin >> v[i];sort(v.begin(),v.end());ll ans = 0;ll now = 1;ll cnt = 0;int f = 0;for (int i = n-1;i >= 0;i--){if (now <= cnt){cnt = 0;now <<= 1LL;f++;}ans += v[i]*f;cnt++;}cout << ans << endl;}