結果

問題 No.885 アマリクエリ
ユーザー tekihei2317
提出日時 2019-09-14 09:31:55
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 464 bytes
コンパイル時間 1,531 ms
コンパイル使用メモリ 171,780 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-05 16:07:32
合計ジャッジ時間 5,729 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }

    priority_queue<int> Q;
    int S=0;
    for(int i=0;i<N;i++){
        Q.push(a[i]); S+=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