結果
問題 |
No.885 アマリクエリ
|
ユーザー |
![]() |
提出日時 | 2019-06-27 00:22:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 387 ms / 2,000 ms |
コード長 | 470 bytes |
コンパイル時間 | 1,756 ms |
コンパイル使用メモリ | 171,604 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 08:02:32 |
合計ジャッジ時間 | 5,842 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; priority_queue<ll> Q; int main(){ ll n,q,x,sum=0; cin>>n; assert(1<=n&&n<=1e5); while(n--){ cin>>x; assert(0<=x&&x<=1e9); sum+=x; Q.push(x); } cin>>q; assert(1<=q&&q<=1e5); while(q--){ cin>>x; assert(1<=x&&x<=1e9); while(!Q.empty()){ ll p=Q.top(); if(p<x)break; Q.pop(); sum-=p; p%=x; sum+=p; Q.push(p); } cout<<sum<<endl; } return 0; }