結果
問題 |
No.885 アマリクエリ
|
ユーザー |
👑 ![]() |
提出日時 | 2020-09-28 20:10:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 327 ms / 2,000 ms |
コード長 | 462 bytes |
コンパイル時間 | 1,593 ms |
コンパイル使用メモリ | 170,336 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-02 10:46:52 |
合計ジャッジ時間 | 6,009 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include<bits/stdc++.h> using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int main() { int N; cin >> N; LL sum = 0; priority_queue<int> G; rep(i, N) { int a; cin >> a; G.push(a); sum += a; } int Q; cin >> Q; while (Q--) { int x; cin >> x; while (G.top() >= x) { int p = G.top(); G.pop(); sum -= p; p %= x; G.push(p); sum += p; } cout << sum << endl; } return 0; }