結果
問題 |
No.885 アマリクエリ
|
ユーザー |
|
提出日時 | 2025-10-01 11:37:34 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,198 ms / 2,000 ms |
コード長 | 732 bytes |
コンパイル時間 | 2,647 ms |
コンパイル使用メモリ | 280,340 KB |
実行使用メモリ | 8,192 KB |
最終ジャッジ日時 | 2025-10-01 11:37:45 |
合計ジャッジ時間 | 9,060 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
// #pragma GCC optimize ("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target ("avx,avx2,fma") #include <bits/stdc++.h> using std::cin, std::cout, std::cerr; using ll = long long; int main() { std::ios::sync_with_stdio(false); int n; cin >> n; ll sum = 0; std::multiset<int> set; for(int i = 1; i <= n; i ++) { int x; cin >> x; sum += x; set.insert(x); } int q; cin >> q; while(q --) { int x; cin >> x; while(*set.rbegin() >= x) { int t = *set.rbegin(); set.erase(set.find(t)); sum -= t; t %= x; set.insert(t); sum += t; } cout << sum << '\n'; } }