#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 5; int a[N], n, q, x; int main() { cin >> n; unordered_map<ll, int> mp; for (int i = 0; i < n; i++) { cin >> a[i]; mp[a[i]]++; } cin >> q; ll cur = 0; while (q--) { cin >> x; cur += x; ll res = 0; for (auto&; kv: mp) { res += abs(kv.first + cur) * kv.second; } cout << res << endl; } return 0; }
牛客网
牛客企业服务