結果

問題 No.885 アマリクエリ
ユーザー le_panda_noirle_panda_noir
提出日時 2020-04-12 15:38:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 376 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 3,126 ms
コンパイル使用メモリ 78,272 KB
実行使用メモリ 5,092 KB
最終ジャッジ日時 2023-10-22 01:19:00
合計ジャッジ時間 7,563 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 376 ms
5,024 KB
testcase_01 AC 285 ms
4,972 KB
testcase_02 AC 225 ms
4,972 KB
testcase_03 AC 222 ms
5,028 KB
testcase_04 AC 225 ms
5,092 KB
testcase_05 AC 190 ms
5,028 KB
testcase_06 AC 161 ms
4,972 KB
testcase_07 AC 44 ms
4,972 KB
testcase_08 AC 171 ms
5,028 KB
testcase_09 AC 286 ms
4,972 KB
testcase_10 AC 2 ms
4,972 KB
testcase_11 AC 2 ms
5,028 KB
testcase_12 AC 2 ms
4,972 KB
testcase_13 AC 4 ms
4,972 KB
testcase_14 AC 4 ms
4,972 KB
testcase_15 AC 4 ms
4,972 KB
testcase_16 AC 4 ms
5,028 KB
testcase_17 AC 4 ms
4,972 KB
testcase_18 AC 4 ms
5,028 KB
testcase_19 AC 3 ms
4,972 KB
testcase_20 AC 4 ms
5,028 KB
testcase_21 AC 3 ms
4,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>

using namespace std;
using ll = long long;

#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0;i<(n);++i)

int main() {
  int in(N);

  priority_queue<int> q;
  ll sum = 0;
  rep(i, N) {
    int in(A);
    sum += A;
    q.push(A);
  }

  int in(Q);
  rep(i, Q) {
    int in(x);
    while (q.top() >= x) {
      int p = q.top(); q.pop();
      sum -= p;
      sum += p % x;
      q.push(p % x);
    }
    cout << sum << endl;
  }

  return 0;
}
0