// compile: g++ -o data data.cpp -O3 -std=gnu++20 -Wall -Wextra -Wshadow -D_GLIBCXX_ASSERTIONS -ggdb3 -fmax-errors=2 -DLOCAL
// run: ./data < data.in
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#include <debug/codeforces.h>
#define debug(x...) {_variables(#x);_print(x);}
#else
#define debug(x...)
#endif
template<typename...Args> void print_(Args...args){((cout<<args<<" "),...)<<endl;}
#define rep(i,a,b) for(int i=(a);i<(int)(b);++i)
#define sz(v) ((int)(v).size())
#define print(...) print_(__VA_ARGS__);
#define INTMAX (int)(9223372036854775807)
#define INTINF (int)(1152921504606846976)
#define int long long
#define MAXN 200010
int binary_search(vector<int> &a, int l, int r, int x) {
// incresing
// largest element <= x
int ans = -1;
while (l <= r) {
int mid = l + (r-l) / 2;
if (a[mid] > x) r = mid - 1;
else ans = mid, l = mid + 1;
}
return ans;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int n, m; cin >> n >> m;
vector<int> a(n), s(n);
rep(i, 0, n) cin >> a[i];
sort(a.begin(), a.end());
rep(i, 0, n) s[i] = i ? s[i-1]+a[i] : a[i];
rep(i, 0, m) {
int x; cin >> x;
int k = binary_search(a, 0, n-1, x);
if (!~k) cout << abs(s[n-1] - n*x) << endl;
else cout << ((k+1)*x - s[k]) + (s[n-1] - s[k] - (n-k-1)*x) << endl;
}
return 0;
}
Downloaded the zt9398app recently and it’s surprisingly well-made. The app runs smoothly on my phone, and it makes betting on the go super convenient. If you’re looking for a mobile option, try zt9398app.
Heiststakesvn caught my eye, seems a cool game. If you want to try something new, click below: heiststakesvn.
Yo, is me777casinolegit actually legit? Answer is YES! Spent a few hours on it last night, and so far, so good. Payouts seem fair too. Give it a whirl here: me777casinolegit
Megaparilogin is pretty straightforward. Login’s simple, and they’ve got a decent range of stuff to play. No complaints so far! Get logged in here: megaparilogin
The Boss777game, I’m kinda feeling it! I’ve been having a good run lately. Site’s not bad, pretty easy to use. Give it a try and become the Boss: boss777game
555betcassino…okay, I’ve played there. Some decent slots, and the bonus offers are alright. Nothing crazy, but solid. Check it out: 555betcassino
Finally found a platform that actually pays out without a hassle. The registration was quick and the slots are incredibly addictive. Give bmw55slotlogin a try.
Great experience so far. The platform is stable and the game selection is perfect for the local market. I am really happy with orobelecuador.
The graphics are stunning and the gameplay is very fluid. It is hard to find a site that balances quality and speed so well. Check out sin88sl for sure.
The registration process was a breeze and I started playing within minutes. It is refreshing to find a site that actually values the players time. Cheers to br393bet11.
Top notch service and a very fair gaming environment. It feels like they actually care about the players. Check out winpgclub for some quality entertainment.
Super intuitive design and the loading times are barely there. It makes the whole experience so much more enjoyable. vnzoo88 is killing it right now.
Having access to games around the clock is such a convenient perk and the mobile site runs flawlessly on my phone. I really like how they handle account updates without making you jump through hoops. A dependable choice for everyday entertainment. instamatch247
[1790]verajohn login করুন – বিকাশ ডিপোজিট ও সেরা স্লট গেম,verajohn অ্যাপ download করে লাইভ ক্যাসিনো খেলার নিয়ম জানুন এবং বিকাশ দিয়ে ক্যাসিনো ডিপোজিট করে আজই আপনার যাত্রা শুরু করুন। visit: verajohn