結果
問題 |
No.1012 荷物収集
|
ユーザー |
|
提出日時 | 2020-04-03 00:51:37 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 245 ms / 2,000 ms |
コード長 | 905 bytes |
コンパイル時間 | 1,446 ms |
コンパイル使用メモリ | 162,552 KB |
実行使用メモリ | 6,656 KB |
最終ジャッジ日時 | 2024-06-28 15:28:29 |
合計ジャッジ時間 | 11,459 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 |
ソースコード
#include <bits/stdc++.h> #include <string> #define ft first #define sc second #define pt(sth) cout << sth << "\n" #define chmax(a, b) a=max(a, b) #define chmin(a, b) a=min(a, b) #define moC(a, s, b) a=((a)s(b)+MOD)%MOD using namespace std; typedef long long ll; typedef pair<ll, ll> pll; static const ll INF=1e18; static const ll MAX=101010; static const ll MOD=1e9+7; /* for(i=0; i<N; i++) cin >> a[i]; */ ll N, Q; pll p[MAX]; int main(void) { ll i, j, k; cin >> N >> Q; p[0]={-INF, -INF}; p[N+1]={INF, INF}; for(i=1; i<=N; i++) cin >> p[i].ft >> p[i].sc; sort(p, p+N+2); ll sw[MAX]={}, sxw[MAX]={}; for(i=1; i<=N; i++) { sw[i]=sw[i-1]+p[i].sc; sxw[i]=sxw[i-1]+p[i].ft*p[i].sc; } for(ll _=0; _<Q; _++) { ll X; cin >> X; ll pos=lower_bound(p, p+N+2, pll(X, -1))-p; pos--; pt(sxw[N]-2*sxw[pos]-X*sw[N]+2*X*sw[pos]); } }