結果
問題 | No.1416 ショッピングモール |
ユーザー |
![]() |
提出日時 | 2021-03-05 21:23:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 1,000 ms |
コード長 | 397 bytes |
コンパイル時間 | 2,121 ms |
コンパイル使用メモリ | 171,092 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-07 00:14:12 |
合計ジャッジ時間 | 3,047 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> A(n); for (int i = 0; i < n; i++){ cin >> A[i]; } sort(A.begin(), A.end(), greater<int>()); vector<int> F(n); F[0] = 0; for (int i = 1; i < n; i++){ F[i] = F[(i - 1) / 2] + 1; } long long ans = 0; for (int i = 0; i < n; i++){ ans += A[i] * F[i]; } cout << ans << endl; }