結果
問題 | No.885 アマリクエリ |
ユーザー |
![]() |
提出日時 | 2020-08-12 13:28:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,589 ms / 2,000 ms |
コード長 | 1,144 bytes |
コンパイル時間 | 1,379 ms |
コンパイル使用メモリ | 118,276 KB |
最終ジャッジ日時 | 2025-01-12 21:19:29 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, const char**)’: main.cpp:29:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | ll a;scanf("%lld", &a); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <iostream> #include <string> #include <vector> #include <queue> #include <deque> #include <algorithm> #include <set> #include <map> #include <bitset> #include <cmath> #include <functional> #include <iomanip> #define vll vector<ll> #define vvvl vector<vvl> #define vvl vector<vector<ll>> #define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c)) #define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d))); #define re(c, b) for(ll c=0;c<b;c++) #define all(obj) (obj).begin(), (obj).end() typedef long long int ll; typedef long double ld; using namespace std; int main(int argc, char const *argv[]) { ll n, q;std::cin >> n; ll s = 0; multiset<ll> st; for(int i=0;i<n;i++){ ll a;scanf("%lld", &a); s += a; st.insert(a); } std::cin >> q; for(int i=0;i<q;i++){ ll t;std::cin >> t; auto itr = st.lower_bound(t); vll c; while(itr!=st.end()){ ll num = (*itr); ll aft = num%t; s += - num + aft; c.push_back(num); itr++; } for(auto e:c){ auto itr = st.find(e); st.erase(itr); st.insert(e%t); } std::cout << s << '\n'; } return 0; }