結果

問題 No.885 アマリクエリ
ユーザー okok
提出日時 2019-09-13 23:52:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 966 bytes
コンパイル時間 824 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 5,812 KB
最終ジャッジ日時 2023-09-17 15:36:05
合計ジャッジ時間 3,291 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 276 ms
5,712 KB
testcase_01 AC 106 ms
5,600 KB
testcase_02 AC 43 ms
5,772 KB
testcase_03 AC 41 ms
5,640 KB
testcase_04 AC 42 ms
5,812 KB
testcase_05 AC 28 ms
5,636 KB
testcase_06 AC 21 ms
5,600 KB
testcase_07 AC 15 ms
4,924 KB
testcase_08 AC 20 ms
4,376 KB
testcase_09 AC 104 ms
5,656 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 3 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, q, sum = 0, maximum = 0;
	// priority_queue<int,vector<int>,greater<int>> Q;
	priority_queue<int> Q;
	vector<int> A, X;
	
	cin>>N;
	
	A.assign(N,0);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		sum += A[i];
		Q.push(A[i]);
	}
	
	cin>>q;
	
	X.assign(q,0);
	
	for(int i = 0; i < q; i++){
		cin>>X[i];
		
			// cout<<Q.top()<<" "<<X[i]<<endl;
		while(Q.top() >= X[i]){
			// cout<<Q.top()<<" "<<X[i]<<endl;
			int x = Q.top(); Q.pop();
			sum -= x - x%X[i];
			Q.push(x%X[i]);
		}
		
		cout<<sum<<endl;
	}
	
	return 0;
}
0