結果

問題 No.1012 荷物収集
ユーザー chocoruskchocorusk
提出日時 2020-03-20 21:45:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 1,010 bytes
コンパイル時間 1,405 ms
コンパイル使用メモリ 116,240 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-05-08 21:32:21
合計ジャッジ時間 9,480 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 230 ms
6,400 KB
testcase_05 AC 233 ms
6,400 KB
testcase_06 AC 230 ms
6,400 KB
testcase_07 AC 235 ms
6,528 KB
testcase_08 AC 235 ms
6,528 KB
testcase_09 AC 237 ms
6,272 KB
testcase_10 AC 236 ms
6,400 KB
testcase_11 AC 240 ms
6,400 KB
testcase_12 AC 238 ms
6,400 KB
testcase_13 AC 239 ms
6,272 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 4 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 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 176 ms
5,376 KB
testcase_25 AC 222 ms
5,760 KB
testcase_26 AC 92 ms
5,504 KB
testcase_27 AC 21 ms
5,376 KB
testcase_28 AC 203 ms
6,016 KB
testcase_29 AC 76 ms
6,272 KB
testcase_30 AC 200 ms
6,400 KB
testcase_31 AC 121 ms
5,376 KB
testcase_32 AC 81 ms
5,376 KB
testcase_33 AC 142 ms
5,376 KB
testcase_34 AC 161 ms
5,376 KB
testcase_35 AC 180 ms
5,888 KB
testcase_36 AC 157 ms
5,376 KB
testcase_37 AC 77 ms
6,016 KB
testcase_38 AC 182 ms
5,376 KB
testcase_39 AC 75 ms
5,376 KB
testcase_40 AC 96 ms
5,376 KB
testcase_41 AC 242 ms
6,272 KB
testcase_42 AC 118 ms
5,376 KB
testcase_43 AC 149 ms
5,504 KB
testcase_44 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
	int n, q;
	cin>>n>>q;
	vector<P> v(n);
	for(int i=0; i<n; i++){
		cin>>v[i].first>>v[i].second;
	}
	sort(v.begin(), v.end());
	ll ws[100010], wxs[100010];
	ws[0]=0, wxs[0]=0;
	for(int i=0; i<n; i++){
		ws[i+1]=ws[i]+v[i].second;
		wxs[i+1]=wxs[i]+v[i].first*v[i].second;
	}
	while(q--){
		ll x;
		cin>>x;
		int k=lower_bound(v.begin(), v.end(), P(x, 0))-v.begin();
		ll ans=x*ws[k]-wxs[k]+(wxs[n]-wxs[k])-x*(ws[n]-ws[k]);
		cout<<ans<<endl;
	}
	return 0;
}
0