/** * author: shu8Cream * created: 20.02.2022 02:59:00 **/ #include using namespace std; #define rep(i,n) for (int i=0; i<(n); i++) #define rrep(i,n) for (int i=(n-1); i>=0; i--) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) int((x).size()) using ll = long long; using P = pair; using vi = vector; using vvi = vector; const ll INF = 8e18; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template string to_string(T s); template string to_string(pair p); string to_string(char c) { return string(1, c); } string to_string(string s) { return s; } string to_string(const char s[]) { return string(s); } template string to_string(T v) { if (v.empty()) return "{}"; string ret = "{"; for (auto x : v) ret += to_string(x) + ","; ret.back() = '}'; return ret; } template string to_string(pair p) { return "{" + to_string(p.first) + ":" + to_string(p.second) + "}"; } void debug_out() { cout << endl; } template void debug_out(Head H, Tail... T) { cout << to_string(H) << " "; debug_out(T...); } #ifdef _DEBUG #define debug(...) debug_out(__VA_ARGS__) #else #define debug(...) #endif int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n,q; cin >> n >> q; vector

X(n); vi t(n); rep(i,n){ cin >> X[i].first >> t[i]; X[i].second = i; } sort(all(X)); vi x(n),w(n); rep(i,n) w[i] = t[X[i].second]; rep(i,n) x[i] = X[i].first; vi rx(n+1), rw(n+1); rep(i,n) rx[i+1] = rx[i]+x[i]*w[i]; rep(i,n) rw[i+1] = rw[i]+w[i]; debug(w); rep(i,q){ ll v; cin >> v; int it = lower_bound(all(x),v) - x.begin(); ll ans = v*rw[it]-rx[it] + (rx[n]-rx[it])-v*(rw[n]-rw[it]); cout << ans << endl; } }