結果

問題 No.1012 荷物収集
ユーザー eQeeQe
提出日時 2020-04-03 00:51:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 241 ms / 2,000 ms
コード長 905 bytes
コンパイル時間 1,907 ms
コンパイル使用メモリ 148,848 KB
実行使用メモリ 6,564 KB
最終ジャッジ日時 2023-09-11 00:56:35
合計ジャッジ時間 12,625 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,924 KB
testcase_01 AC 3 ms
4,956 KB
testcase_02 AC 2 ms
4,980 KB
testcase_03 AC 2 ms
4,924 KB
testcase_04 AC 237 ms
6,480 KB
testcase_05 AC 238 ms
6,532 KB
testcase_06 AC 240 ms
6,560 KB
testcase_07 AC 238 ms
6,484 KB
testcase_08 AC 239 ms
6,484 KB
testcase_09 AC 238 ms
6,564 KB
testcase_10 AC 237 ms
6,548 KB
testcase_11 AC 240 ms
6,560 KB
testcase_12 AC 235 ms
6,556 KB
testcase_13 AC 240 ms
6,564 KB
testcase_14 AC 3 ms
5,012 KB
testcase_15 AC 4 ms
4,920 KB
testcase_16 AC 3 ms
5,196 KB
testcase_17 AC 4 ms
4,992 KB
testcase_18 AC 4 ms
4,920 KB
testcase_19 AC 3 ms
4,924 KB
testcase_20 AC 3 ms
5,028 KB
testcase_21 AC 4 ms
4,936 KB
testcase_22 AC 4 ms
5,004 KB
testcase_23 AC 3 ms
4,932 KB
testcase_24 AC 183 ms
5,768 KB
testcase_25 AC 229 ms
6,204 KB
testcase_26 AC 93 ms
6,056 KB
testcase_27 AC 22 ms
5,192 KB
testcase_28 AC 211 ms
6,308 KB
testcase_29 AC 75 ms
6,448 KB
testcase_30 AC 205 ms
6,504 KB
testcase_31 AC 129 ms
4,996 KB
testcase_32 AC 84 ms
5,308 KB
testcase_33 AC 150 ms
5,304 KB
testcase_34 AC 166 ms
5,160 KB
testcase_35 AC 177 ms
6,440 KB
testcase_36 AC 160 ms
5,052 KB
testcase_37 AC 74 ms
6,316 KB
testcase_38 AC 184 ms
5,976 KB
testcase_39 AC 75 ms
5,548 KB
testcase_40 AC 101 ms
5,412 KB
testcase_41 AC 241 ms
6,472 KB
testcase_42 AC 126 ms
5,508 KB
testcase_43 AC 153 ms
5,976 KB
testcase_44 AC 3 ms
4,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) a=max(a, b)
#define chmin(a, b) a=min(a, b)
#define moC(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll N, Q;
pll p[MAX];

int main(void) {
  ll i, j, k;
  
  cin >> N >> Q;
  
  p[0]={-INF, -INF};
  p[N+1]={INF, INF};
  for(i=1; i<=N; i++) cin >> p[i].ft >> p[i].sc;
  sort(p, p+N+2);
  
  ll sw[MAX]={}, sxw[MAX]={};
  for(i=1; i<=N; i++) {
    sw[i]=sw[i-1]+p[i].sc;
    sxw[i]=sxw[i-1]+p[i].ft*p[i].sc;
  }
  
  for(ll _=0; _<Q; _++) {
    ll X;
    cin >> X;
    
    ll pos=lower_bound(p, p+N+2, pll(X, -1))-p;
    pos--;
    pt(sxw[N]-2*sxw[pos]-X*sw[N]+2*X*sw[pos]);
  }
  
  
  
}


0