結果

問題 No.885 アマリクエリ
コンテスト
ユーザー QCFium
提出日時 2019-06-26 09:04:05
言語 C++11
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 233 ms / 2,000 ms
+ 826µs
コード長 434 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 504 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-28 10:29:50
合計ジャッジ時間 3,827 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <queue>
#include <iostream>

int ri() {
	int n;
	std::cin >> n;
	return n;
}

int main() {
	int n = ri();
	std::priority_queue<int> que;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		int a = ri();
		sum += a;
		que.push(a);
	}
	int q = ri();
	for (int i = 0; i < q; i++) {
		int x = ri();
		int t;
		while ((t = que.top()) >= x) sum -= t - t % x, que.pop(), que.push(t % x);
		printf("%lld\n", sum);
	}
	
	return 0;
}
0