結果
問題 | No.885 アマリクエリ |
ユーザー | tempura_pp |
提出日時 | 2019-09-13 22:06:53 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 431 ms / 2,000 ms |
コード長 | 977 bytes |
コンパイル時間 | 896 ms |
コンパイル使用メモリ | 102,400 KB |
実行使用メモリ | 9,872 KB |
最終ジャッジ日時 | 2023-09-17 14:24:11 |
合計ジャッジ時間 | 4,711 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 184 ms
4,380 KB |
testcase_01 | AC | 410 ms
9,604 KB |
testcase_02 | AC | 278 ms
9,600 KB |
testcase_03 | AC | 212 ms
4,380 KB |
testcase_04 | AC | 215 ms
4,380 KB |
testcase_05 | AC | 189 ms
4,380 KB |
testcase_06 | AC | 163 ms
4,376 KB |
testcase_07 | AC | 65 ms
9,872 KB |
testcase_08 | AC | 174 ms
4,380 KB |
testcase_09 | AC | 431 ms
9,552 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 2 ms
4,384 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | AC | 5 ms
4,376 KB |
testcase_14 | AC | 5 ms
4,380 KB |
testcase_15 | AC | 5 ms
4,380 KB |
testcase_16 | AC | 4 ms
4,380 KB |
testcase_17 | AC | 4 ms
4,380 KB |
testcase_18 | AC | 4 ms
4,380 KB |
testcase_19 | AC | 2 ms
4,380 KB |
testcase_20 | AC | 3 ms
4,380 KB |
testcase_21 | AC | 2 ms
4,376 KB |
ソースコード
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<stack> #include<map> #include<set> #include<bitset> #include<functional> #include<assert.h> #include<numeric> using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) using ll = long long; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; int main(){ int n; cin>>n; map<ll,ll> mp; ll ans = 0; rep(i,n){ int x; cin>>x; ans+=x; mp[x]++; } int q; cin>>q; while(q--){ int y; cin>>y; auto itr = mp.lower_bound(y); while(itr!=mp.end()){ ll cur = itr->first, cnt = itr->second; ans -= (cur-cur%y)*cnt; mp[cur%y]+=cnt; itr = mp.erase(itr); } cout<<ans<<endl; } return 0; }