Untitled

 avatar
unknown
c_cpp
a year ago
703 B
20
Indexable
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int tt, tc;

void solve() {
    int n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for (ll& u : a) cin >> u;

    sort(a.begin(), a.end());

    vector<ll> p = a;
    for (int i = 1; i < n; i++) p[i] += p[i - 1];

    while (q--) {
        ll x;
        cin >> x;
        int j = lower_bound(a.begin(), a.end(), x) - a.begin();
        if (j == 0) {
            cout << 0 << "\n";
            continue;
        }
        cout << 50LL * (x * 1LL * j - p[j - 1]) << "\n";
    } 
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    tt = 1, tc = 1; // cin >> tt;
    while (tt--) solve(), tc++;
}
Editor is loading...
Leave a Comment