結果
| 問題 | No.1416 ショッピングモール |
| コンテスト | |
| ユーザー |
yukster714
|
| 提出日時 | 2023-05-18 20:26:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 1,000 ms |
| コード長 | 797 bytes |
| 記録 | |
| コンパイル時間 | 787 ms |
| コンパイル使用メモリ | 74,620 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-16 09:18:05 |
| 合計ジャッジ時間 | 2,150 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
int main() {
int n; cin >>n;
vector<int>a(n);
rep(i,n) cin>>a[i];
sort(a.begin(),a.end(), greater<int>());
int ans = 0;
int max_capacity_on_floor_k = 1;
int k=0;
int i=0;
int total_cost = 0;
while(i<n){
if(k>0) max_capacity_on_floor_k *=2;
int number_of_shops_on_floor_k = 1;
int cost_on_floor_k = 0;
while(number_of_shops_on_floor_k <= max_capacity_on_floor_k){
if(i>=n) break;
cost_on_floor_k += a[i]*k;
i++;
number_of_shops_on_floor_k++;
}
total_cost+=cost_on_floor_k;
k++;
}
cout << total_cost << endl;
return 0;
}
yukster714