結果
| 問題 |
No.1416 ショッピングモール
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-05 21:26:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 1,000 ms |
| コード長 | 501 bytes |
| コンパイル時間 | 682 ms |
| コンパイル使用メモリ | 79,232 KB |
| 最終ジャッジ日時 | 2025-01-19 10:35:31 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#line 1 "main.cpp"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> xs(n);
for (auto& x : xs) cin >> x;
sort(xs.rbegin(), xs.rend());
int ans = 0, k = -1;
for (int i = 0; i < n; ++i) {
if (__builtin_popcount(i + 1) == 1) ++k;
ans += xs[i] * k;
}
cout << ans << "\n";
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
solve();
return 0;
}