結果

問題 No.1012 荷物収集
ユーザー face4face4
提出日時 2020-07-06 17:00:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,014 bytes
コンパイル時間 842 ms
コンパイル使用メモリ 80,504 KB
実行使用メモリ 7,700 KB
最終ジャッジ日時 2023-10-24 22:06:35
合計ジャッジ時間 11,969 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 4 ms
4,348 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 3 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
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,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

int main(){
    int n, q;
    cin >> n >> q;
    vector<pii> vp;
    for(int i = 0; i < n; i++){
        int x, w;
        cin >> x >> w;
        vp.push_back({x,w});
    }
    sort(vp.begin(), vp.end());
    vector<pii> ev;
    ev = vp;
    for(int i = 1; i <= q; i++){
        int x;
        cin >> x;
        ev.push_back({x, -i});
    }
    sort(ev.begin(), ev.end());
    int st = ev[0].first;
    ll tmp = 0, l = 0, r = 0;
    for(int i = 0; i < n; i++){
        tmp += (vp[i].first-st)*vp[i].second;
        r += vp[i].second;
    }
    vector<ll> ans(q+1);
    for(pii p : ev){
        int x = p.first, y = p.second;
        int diff = x-st;
        tmp += diff*l - diff*r;
        if(y < 0){
            ans[-y] = tmp;
        }else{
            l += y;
            r -= y;
        }
        st = x;
    }
    for(int i = 1; i <= q; i++) cout << ans[i] << endl;
    return 0;
}
0