結果

問題 No.885 アマリクエリ
ユーザー tekihei2317tekihei2317
提出日時 2019-09-14 09:31:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 464 bytes
コンパイル時間 1,862 ms
コンパイル使用メモリ 170,556 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-19 03:29:01
合計ジャッジ時間 7,351 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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