結果

問題 No.885 アマリクエリ
ユーザー tekihei2317
提出日時 2019-09-13 23:06:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 371 ms / 2,000 ms
コード長 511 bytes
コンパイル時間 1,838 ms
コンパイル使用メモリ 172,620 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-04 10:21:33
合計ジャッジ時間 5,198 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    int S=accumulate(a.begin(),a.end(),0LL);
    priority_queue<int> Q;
    for(int i=0;i<N;i++){
        Q.push(a[i]);
    }

    int q; cin>>q;
    while(q--){
        int x; cin>>x;
        while(Q.top()>=x){
            int t=Q.top(); Q.pop();
            S-=t-t%x;
            Q.push(t%x);
        }
        cout<<S<<endl;
    }
}
0