結果

問題 No.885 アマリクエリ
ユーザー tekihei2317tekihei2317
提出日時 2019-09-14 09:32:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 396 ms / 2,000 ms
コード長 489 bytes
コンパイル時間 1,960 ms
コンパイル使用メモリ 170,648 KB
実行使用メモリ 4,956 KB
最終ジャッジ日時 2023-09-19 03:32:03
合計ジャッジ時間 6,110 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 396 ms
4,912 KB
testcase_01 AC 280 ms
4,900 KB
testcase_02 AC 221 ms
4,820 KB
testcase_03 AC 219 ms
4,824 KB
testcase_04 AC 222 ms
4,896 KB
testcase_05 AC 185 ms
4,828 KB
testcase_06 AC 158 ms
4,936 KB
testcase_07 AC 41 ms
4,956 KB
testcase_08 AC 168 ms
4,380 KB
testcase_09 AC 284 ms
4,916 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 4 ms
4,384 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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];
    }

    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