結果

問題 No.1012 荷物収集
ユーザー chocoruskchocorusk
提出日時 2020-03-20 21:45:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 1,010 bytes
コンパイル時間 2,512 ms
コンパイル使用メモリ 114,708 KB
実行使用メモリ 6,460 KB
最終ジャッジ日時 2023-08-21 16:00:36
合計ジャッジ時間 10,715 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 235 ms
6,460 KB
testcase_05 AC 236 ms
6,272 KB
testcase_06 AC 234 ms
6,272 KB
testcase_07 AC 236 ms
6,156 KB
testcase_08 AC 237 ms
6,212 KB
testcase_09 AC 238 ms
6,256 KB
testcase_10 AC 237 ms
6,256 KB
testcase_11 AC 238 ms
6,324 KB
testcase_12 AC 234 ms
6,256 KB
testcase_13 AC 237 ms
6,276 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 3 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,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 181 ms
4,620 KB
testcase_25 AC 224 ms
5,624 KB
testcase_26 AC 94 ms
5,276 KB
testcase_27 AC 21 ms
4,380 KB
testcase_28 AC 213 ms
6,104 KB
testcase_29 AC 77 ms
6,264 KB
testcase_30 AC 206 ms
6,164 KB
testcase_31 AC 125 ms
4,376 KB
testcase_32 AC 82 ms
4,376 KB
testcase_33 AC 142 ms
4,380 KB
testcase_34 AC 165 ms
4,376 KB
testcase_35 AC 175 ms
5,480 KB
testcase_36 AC 156 ms
4,376 KB
testcase_37 AC 75 ms
6,000 KB
testcase_38 AC 185 ms
4,840 KB
testcase_39 AC 74 ms
4,376 KB
testcase_40 AC 98 ms
4,380 KB
testcase_41 AC 237 ms
5,884 KB
testcase_42 AC 124 ms
4,376 KB
testcase_43 AC 150 ms
5,092 KB
testcase_44 AC 1 ms
4,380 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