結果

問題 No.1012 荷物収集
ユーザー saxofone111saxofone111
提出日時 2021-03-15 14:49:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 1,162 bytes
コンパイル時間 2,460 ms
コンパイル使用メモリ 203,312 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-04-24 17:58:16
合計ジャッジ時間 12,121 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 2 ms
5,248 KB
testcase_04 AC 228 ms
6,400 KB
testcase_05 AC 235 ms
6,400 KB
testcase_06 AC 236 ms
6,400 KB
testcase_07 AC 232 ms
6,400 KB
testcase_08 AC 236 ms
6,528 KB
testcase_09 AC 231 ms
6,400 KB
testcase_10 AC 229 ms
6,528 KB
testcase_11 AC 244 ms
6,400 KB
testcase_12 AC 235 ms
6,656 KB
testcase_13 AC 230 ms
6,400 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 171 ms
5,376 KB
testcase_25 AC 216 ms
5,888 KB
testcase_26 AC 94 ms
5,376 KB
testcase_27 AC 21 ms
5,376 KB
testcase_28 AC 205 ms
6,272 KB
testcase_29 AC 76 ms
6,272 KB
testcase_30 AC 202 ms
6,272 KB
testcase_31 AC 123 ms
5,376 KB
testcase_32 AC 84 ms
5,376 KB
testcase_33 AC 141 ms
5,376 KB
testcase_34 AC 158 ms
5,376 KB
testcase_35 AC 171 ms
5,760 KB
testcase_36 AC 156 ms
5,376 KB
testcase_37 AC 76 ms
6,144 KB
testcase_38 AC 178 ms
5,376 KB
testcase_39 AC 74 ms
5,376 KB
testcase_40 AC 96 ms
5,376 KB
testcase_41 AC 240 ms
6,400 KB
testcase_42 AC 121 ms
5,376 KB
testcase_43 AC 145 ms
5,504 KB
testcase_44 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  ll Q;
  cin >> Q;
  vector<P> v(N);
  rep(i, N){
    cin >> v[i].fi >> v[i].se;
  }
  sort(ALL(v));
  llvec S(N+1, 0);
  llvec T(N+1, 0);
  rep(i, N){
    S[i+1] = S[i] +v[i].fi*v[i].se;
    T[i+1] = T[i] +v[i].se;
  }

  while(Q--){
    ll x;
    cin >> x;
    P f = {x, 0};
    ll m = lower_bound(ALL(v), f) - v.begin();
    ll ans =  T[m]*x- S[m] + (S[N]-S[m]) - (T[N]-T[m])*x;
    cout << ans << endl;
  }
  
  return 0;
}
0