結果

問題 No.1012 荷物収集
ユーザー merom686merom686
提出日時 2020-03-20 22:10:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 783 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 78,160 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2024-05-08 22:17:58
合計ジャッジ時間 4,739 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 43 ms
5,504 KB
testcase_05 AC 43 ms
5,632 KB
testcase_06 AC 43 ms
5,632 KB
testcase_07 AC 43 ms
5,504 KB
testcase_08 AC 42 ms
5,504 KB
testcase_09 AC 43 ms
5,632 KB
testcase_10 AC 42 ms
5,632 KB
testcase_11 AC 43 ms
5,632 KB
testcase_12 AC 43 ms
5,632 KB
testcase_13 AC 42 ms
5,632 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
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, q;
    cin >> n >> q;

    vector<int> x(n), w(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> w[i];
    }

    vector<ll> s0(n + 1), w0(n + 1);
    for (int i = 0; i < n; i++) {
        s0[i + 1] = s0[i] + (ll)x[i] * w[i];
        w0[i + 1] = w0[i] + w[i];
    }

    for (int _ = 0; _ < q; _++) {
        int X;
        cin >> X;

        int k = lower_bound(x.begin(), x.end(), X) - x.begin();
        ll r = -s0[k] + X * w0[k] + (s0[n] - s0[k]) - X * (w0[n] - w0[k]);
        cout << r << '\n';
    }

    return 0;
}
0