結果
問題 |
No.1416 ショッピングモール
|
ユーザー |
![]() |
提出日時 | 2021-03-06 00:25:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 1,000 ms |
コード長 | 720 bytes |
コンパイル時間 | 1,894 ms |
コンパイル使用メモリ | 173,384 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 06:53:06 |
合計ジャッジ時間 | 2,758 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <algorithm> #include <bits/stdc++.h> using namespace std; using ll=long long; bool chmin(int& a, int b){ if(a > b){ a = b; return 1; } return 0; } bool chmax(int& a, int b){ if(a < b){ a = b; return 1; } return 0; } constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } const ll MOD = 1000000007LL; int main() { ll n; cin >> n; vector<ll> as(n); for (auto& a : as) cin >> a; sort(as.begin(), as.end(), greater<>()); ll cnt = 0, t = 1, floor=0, ans = 0; for (ll a : as) { if (cnt == t) { cnt = 0; floor++; t *= 2; } ans += a * floor; cnt++; } cout << ans << endl; return 0; }