結果
問題 |
No.1012 荷物収集
|
ユーザー |
![]() |
提出日時 | 2020-03-20 21:52:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 989 bytes |
コンパイル時間 | 1,860 ms |
コンパイル使用メモリ | 178,580 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-15 05:28:38 |
合計ジャッジ時間 | 5,293 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 11 WA * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; const lint inf = 1LL << 60; const lint mod = 1000000007; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); lint n, q; cin >> n >> q; vector<pair<lint, lint>> xw(n); lint weight = 0; lint cost = 0; for (int i = 0; i < n; ++i) { cin >> xw[i].first >> xw[i].second; weight -= xw[i].second; cost += abs(xw[i].first - 1) * xw[i].second; } sort(xw.begin(), xw.end()); vector<lint> y(q); for (int i = 0; i < q; ++i) { cin >> y[i]; } sort(y.begin(), y.end()); lint pos = 1; lint posx = 0; for (int i = 0; i < q; ++i) { while (posx < n && xw[posx].first < y[i]) { cost += weight * (xw[posx].first - pos); weight += xw[posx].second * 2; pos = xw[posx].first; posx++; } cout << cost + weight * (y[i] - pos) << "\n"; } return 0; }