結果

問題 No.1012 荷物収集
ユーザー micheeeeell1001micheeeeell1001
提出日時 2020-03-20 22:20:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 1,510 bytes
コンパイル時間 1,733 ms
コンパイル使用メモリ 173,372 KB
実行使用メモリ 8,828 KB
最終ジャッジ日時 2023-08-21 17:04:49
合計ジャッジ時間 7,642 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 110 ms
8,584 KB
testcase_05 AC 109 ms
8,560 KB
testcase_06 AC 109 ms
8,828 KB
testcase_07 AC 109 ms
8,512 KB
testcase_08 AC 109 ms
8,540 KB
testcase_09 AC 109 ms
8,516 KB
testcase_10 AC 109 ms
8,472 KB
testcase_11 AC 109 ms
8,540 KB
testcase_12 AC 109 ms
8,824 KB
testcase_13 AC 109 ms
8,560 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 86 ms
5,996 KB
testcase_25 AC 115 ms
7,560 KB
testcase_26 AC 67 ms
6,572 KB
testcase_27 AC 17 ms
4,380 KB
testcase_28 AC 114 ms
7,724 KB
testcase_29 AC 74 ms
7,616 KB
testcase_30 AC 119 ms
8,204 KB
testcase_31 AC 41 ms
4,376 KB
testcase_32 AC 38 ms
4,380 KB
testcase_33 AC 57 ms
4,708 KB
testcase_34 AC 60 ms
4,376 KB
testcase_35 AC 99 ms
7,288 KB
testcase_36 AC 53 ms
4,380 KB
testcase_37 AC 70 ms
7,192 KB
testcase_38 AC 91 ms
6,468 KB
testcase_39 AC 43 ms
4,848 KB
testcase_40 AC 49 ms
4,916 KB
testcase_41 AC 127 ms
8,044 KB
testcase_42 AC 60 ms
5,088 KB
testcase_43 AC 83 ms
6,792 KB
testcase_44 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll n,q; cin >> n >> q;
    vector<ll> a(n),b(n);
    vector<Pll> ab(n);
    rep(i,n){
        ll a,b; cin >> a >> b;
        ab[i] = {a,b};
    }
    sort(all(ab));
    rep(i,n){
        a[i] = ab[i].first;
        b[i] = ab[i].second;
    }
    // rep(i,n)cin >> a[i] >> b[i];
    vector<ll> sum_ab(n+1), sum_b(n+1);
    rep(i,n){
        sum_ab[i+1] = sum_ab[i] + a[i] * b[i];
        sum_b[i+1] = sum_b[i] + b[i];
    }
    vector<ll> x(q);
    rep(i,q) cin >> x[i];
    rep(i,q){
        ll id = lower_bound(all(a), x[i]) - a.begin();
        // debug(id);
        ll ans = 0;
        ans -= sum_ab[id] - sum_ab[0];
        ans += sum_ab[n] - sum_ab[id];
        ans += x[i] * (sum_b[id] - sum_b[0]);
        ans -= x[i] * (sum_b[n] - sum_b[id]);
        cout << ans << "\n";
    }
}
0