結果

問題 No.1416 ショッピングモール
ユーザー yukster714yukster714
提出日時 2023-05-18 20:26:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 1,000 ms
コード長 797 bytes
コンパイル時間 692 ms
コンパイル使用メモリ 74,732 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-22 12:22:22
合計ジャッジ時間 2,276 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 12 ms
4,376 KB
testcase_22 AC 13 ms
4,376 KB
testcase_23 AC 14 ms
4,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0