結果
問題 | No.885 アマリクエリ |
ユーザー | 👑 hos.lyric |
提出日時 | 2019-09-13 22:07:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 251 ms / 2,000 ms |
コード長 | 1,652 bytes |
コンパイル時間 | 1,138 ms |
コンパイル使用メモリ | 110,564 KB |
実行使用メモリ | 9,204 KB |
最終ジャッジ日時 | 2023-09-17 14:24:30 |
合計ジャッジ時間 | 3,357 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
4,376 KB |
testcase_01 | AC | 210 ms
8,924 KB |
testcase_02 | AC | 79 ms
9,204 KB |
testcase_03 | AC | 36 ms
4,380 KB |
testcase_04 | AC | 37 ms
4,376 KB |
testcase_05 | AC | 30 ms
4,380 KB |
testcase_06 | AC | 24 ms
4,376 KB |
testcase_07 | AC | 37 ms
8,576 KB |
testcase_08 | AC | 22 ms
4,380 KB |
testcase_09 | AC | 251 ms
8,972 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 1 ms
4,380 KB |
testcase_12 | AC | 1 ms
4,380 KB |
testcase_13 | AC | 3 ms
4,376 KB |
testcase_14 | AC | 3 ms
4,376 KB |
testcase_15 | AC | 3 ms
4,376 KB |
testcase_16 | AC | 2 ms
4,376 KB |
testcase_17 | AC | 2 ms
4,376 KB |
testcase_18 | AC | 2 ms
4,376 KB |
testcase_19 | AC | 2 ms
4,376 KB |
testcase_20 | AC | 1 ms
4,380 KB |
testcase_21 | AC | 2 ms
4,384 KB |
ソースコード
#pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") // #pragma GCC target ("avx") #include <cassert> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using Int = long long; template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template <class T> void chmin(T &t, const T &f) { if (t > f) t = f; } template <class T> void chmax(T &t, const T &f) { if (t < f) t = f; } int N; int A[100010]; int Q; int X[100010]; int main() { for (; ~scanf("%d", &N); ) { for (int i = 0; i < N; ++i) { scanf("%d", &A[i]); } scanf("%d", &Q); for (int q = 0; q < Q; ++q) { scanf("%d", &X[q]); } Int sum = 0; map<int, int> cnt; for (int i = 0; i < N; ++i) { sum += A[i]; ++cnt[A[i]]; } for (int q = 0; q < Q; ++q) { for (auto it = cnt.lower_bound(X[q]); it != cnt.end(); ) { auto itNxt = it; ++itNxt; sum -= (Int)(it->first - it->first % X[q]) * it->second; cnt[it->first % X[q]] += it->second; cnt.erase(it); it = itNxt; } printf("%lld\n", sum); } } return 0; }