結果

問題 No.885 アマリクエリ
ユーザー tekihei2317tekihei2317
提出日時 2019-09-13 23:06:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 382 ms / 2,000 ms
コード長 511 bytes
コンパイル時間 1,730 ms
コンパイル使用メモリ 171,808 KB
実行使用メモリ 4,956 KB
最終ジャッジ日時 2023-09-17 15:13:30
合計ジャッジ時間 5,603 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 382 ms
4,768 KB
testcase_01 AC 287 ms
4,956 KB
testcase_02 AC 219 ms
4,784 KB
testcase_03 AC 222 ms
4,820 KB
testcase_04 AC 225 ms
4,828 KB
testcase_05 AC 190 ms
4,816 KB
testcase_06 AC 159 ms
4,956 KB
testcase_07 AC 41 ms
4,780 KB
testcase_08 AC 167 ms
4,376 KB
testcase_09 AC 284 ms
4,820 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,380 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];
    }
    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