結果

問題 No.1012 荷物収集
ユーザー kibunakibuna
提出日時 2020-03-20 21:52:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 989 bytes
コンパイル時間 2,506 ms
コンパイル使用メモリ 175,604 KB
実行使用メモリ 5,532 KB
最終ジャッジ日時 2023-08-21 16:17:10
合計ジャッジ時間 6,472 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 45 ms
5,440 KB
testcase_05 AC 45 ms
5,416 KB
testcase_06 AC 44 ms
5,360 KB
testcase_07 AC 45 ms
5,416 KB
testcase_08 AC 45 ms
5,360 KB
testcase_09 AC 45 ms
5,392 KB
testcase_10 AC 45 ms
5,448 KB
testcase_11 AC 45 ms
5,532 KB
testcase_12 AC 45 ms
5,408 KB
testcase_13 AC 45 ms
5,364 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0