結果
問題 | No.1416 ショッピングモール |
ユーザー |
![]() |
提出日時 | 2021-03-05 21:29:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 1,000 ms |
コード長 | 983 bytes |
コンパイル時間 | 2,000 ms |
コンパイル使用メモリ | 199,260 KB |
最終ジャッジ日時 | 2025-01-19 10:38:49 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h>using namespace std;struct iofast_t {iofast_t() {ios::sync_with_stdio(false);cin.tie(nullptr); cout.tie(nullptr);}} iofast;struct uns_t {} uns;template <typename Element, typename Head, typename ...Args>auto vec(Element init, Head arg, Args ...args) {if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);else return std::vector(arg, vec(init, args...));}template <typename Element, typename Head, typename ...Args>auto vec(uns_t, Head arg, Args ...args) {return vec(Element(), arg, args...);}int main() {int n; cin >> n;auto a = vec<int>(uns, n);for (auto &e : a) cin >> e;sort(rbegin(a), rend(a));int ans = 0;int count = 0, limit = 1, enter = 0;for (auto e : a) {ans += count * e;++enter;if (limit <= enter) {enter = 0;limit *= 2;++count;}}cout << ans << endl;}