結果
| 問題 |
No.885 アマリクエリ
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2019-09-13 22:31:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 170 ms / 2,000 ms |
| コード長 | 875 bytes |
| コンパイル時間 | 757 ms |
| コンパイル使用メモリ | 87,656 KB |
| 実行使用メモリ | 8,192 KB |
| 最終ジャッジ日時 | 2024-07-04 10:03:08 |
| 合計ジャッジ時間 | 2,585 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
ll s = 0;
map<int, int, greater<>> mp;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
s += a;
mp[a]++;
}
int q;
cin >> q;
for (int h = 0; h < q; h++) {
int x;
cin >> x;
while (1) {
auto it = mp.begin();
if (it->first < x) break;
int a = it->first;
int c = it->second;
mp.erase(it);
int b = a % x;
mp[b] += c;
s -= (ll)(a - b) * c;
}
cout << s << '\n';
}
return 0;
}
merom686