結果

問題 No.1416 ショッピングモール
ユーザー yicodeyicode
提出日時 2023-06-29 13:05:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 1,000 ms
コード長 913 bytes
コンパイル時間 1,703 ms
コンパイル使用メモリ 169,856 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 08:31:58
合計ジャッジ時間 2,801 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using ull = unsigned long long;
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
long long mod = 1000000007;
int main() {
  long long N; cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  long long count = 0;
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int z = 0;
  long long ans = 0;
  bool fire = false;
  while(true) {
    long long x = 1ll << count;
    for(int i = 0;i < x; i++) {
      ans += A[z] * count;
      z++;
      if(z >= N) {
        fire = true;
        break;
      }
    }
    if(fire) {
      break;
    }
    count++;
  }
  cout << ans << endl;
}
0