結果
| 問題 |
No.1416 ショッピングモール
|
| コンテスト | |
| ユーザー |
yukileo9
|
| 提出日時 | 2021-07-12 08:40:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 1,000 ms |
| コード長 | 670 bytes |
| コンパイル時間 | 1,638 ms |
| コンパイル使用メモリ | 170,952 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-02 03:19:33 |
| 合計ジャッジ時間 | 2,929 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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