結果
| 問題 | No.885 アマリクエリ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-18 00:27:59 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 548 ms / 2,000 ms |
| + 936µs | |
| コード長 | 895 bytes |
| 記録 | |
| コンパイル時間 | 367 ms |
| コンパイル使用メモリ | 80,640 KB |
| 実行使用メモリ | 9,088 KB |
| 最終ジャッジ日時 | 2026-09-18 00:28:05 |
| 合計ジャッジ時間 | 5,047 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#include <iostream>
#include <cstdio>
#include <set>
using namespace std;
typedef long long LL;
const int N = 100010;
LL ans;
int n, a[N], q;
multiset<int> ms;
int main() {
// freopen("remainder.in", "r", stdin);
// freopen("remainder.out", "w", stdout);
// clock_t bg = clock();
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", &a[i]);
ans += a[i];
ms.insert(a[i]);
}
scanf("%d", &q);
while (q--) {
int x;
scanf("%d", &x);
auto l = ms.lower_bound(x);
for (auto it = l; it != ms.end(); ) {
int num = *it;
ans -= num - (num % x);
it = ms.erase(it);
num %= x;
ms.insert(num);
}
printf("%lld\n", ans);
}
// clock_t ed = clock();
// printf("%.3lf\n", 1.0 * (ed - bg) / CLOCKS_PER_SEC);
return 0;
}