結果
| 問題 | No.1416 ショッピングモール |
| コンテスト | |
| ユーザー |
yukileo9
|
| 提出日時 | 2021-07-12 08:40:27 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 1,000 ms |
| コード長 | 670 bytes |
| 記録 | |
| コンパイル時間 | 1,079 ms |
| コンパイル使用メモリ | 186,064 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2026-03-23 06:57:40 |
| 合計ジャッジ時間 | 2,100 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void no_1416(void) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
long long cost = 0;
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
int ptr = 0;
bool is_end = false;
for (int i = 0; pow(2, i) <= n; i++) {
for (int j = 0; j < pow(2, i);j++){
cost += (a[ptr]*i);
ptr++;
if(ptr==n){
is_end = true;
break;
}
}
if(is_end){
cout << cost << endl;
return;
}
}
}
int main(void) {
no_1416();
return 0;
}
yukileo9