#include #include #include #include #include #include #include using namespace std; using ll = long long; struct P { bool operator<(const P& p) const { return x < p.x; } int x, w; }; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; vector

p(n); for (int i = 0; i < n; i++) { int x, w; cin >> x >> w; p[i] = { x, w }; } sort(p.begin(), p.end()); vector s0(n + 1), w0(n + 1); for (int i = 0; i < n; i++) { s0[i + 1] = s0[i] + (ll)p[i].x * p[i].w; w0[i + 1] = w0[i] + p[i].w; } for (int _ = 0; _ < q; _++) { int x; cin >> x; int k = lower_bound(p.begin(), p.end(), P{ x, 0 }) - p.begin(); ll r = -s0[k] + x * w0[k] + (s0[n] - s0[k]) - x * (w0[n] - w0[k]); cout << r << '\n'; } return 0; }