結果

問題 No.885 アマリクエリ
ユーザー otoshigootoshigo
提出日時 2024-04-23 14:29:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 525 bytes
コンパイル時間 2,496 ms
コンパイル使用メモリ 202,208 KB
実行使用メモリ 10,440 KB
最終ジャッジ日時 2024-04-23 14:29:49
合計ジャッジ時間 4,868 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 93 ms
8,704 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 29 ms
5,376 KB
testcase_06 AC 21 ms
5,376 KB
testcase_07 AC 41 ms
8,704 KB
testcase_08 AC 21 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin>>N;
	vector<ll>A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	int Q;
	cin>>Q;
	ll sum=0;
	set<ll>se;
	for(int i=0;i<N;i++){
		sum+=A[i];
		se.insert(-A[i]);
	}
	while(Q--){
		ll X;
		cin>>X;
		vector<ll>V;
		while(se.size()&&X<=-*se.begin()){
			ll a=-*se.begin();
			sum-=a;
			se.erase(se.find(-a));
			sum+=a%X;
			V.push_back(a%X);
		}
		for(auto x:V)se.insert(-x);
		cout<<sum<<"\n";
	}
}
0