結果
問題 | No.885 アマリクエリ |
ユーザー |
![]() |
提出日時 | 2019-09-13 21:51:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 228 ms / 2,000 ms |
コード長 | 602 bytes |
コンパイル時間 | 1,510 ms |
コンパイル使用メモリ | 171,144 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-04 04:10:39 |
合計ジャッジ時間 | 3,694 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(),(x).end() const int mod=1000000007,MAX=1<<18; const ll INF=1LL<<55; int main(){ int N;cin>>N; priority_queue<ll> PQ; ll sum=0; for(int i=0;i<N;i++){ ll a; scanf("%lld",&a); PQ.push(a); sum+=a; } int Q;cin>>Q; for(int i=0;i<Q;i++){ ll a; scanf("%lld",&a); while(PQ.top()>=a){ ll b=PQ.top();PQ.pop(); sum-=b/a*a; PQ.push(b%a); } printf("%lld\n",sum); } }