結果

問題 No.1012 荷物収集
ユーザー kotatsugamekotatsugame
提出日時 2020-03-24 20:29:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 777 ms
コンパイル使用メモリ 76,500 KB
実行使用メモリ 5,560 KB
最終ジャッジ日時 2023-08-30 05:51:14
合計ジャッジ時間 11,083 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 224 ms
5,448 KB
testcase_05 AC 223 ms
5,384 KB
testcase_06 AC 224 ms
5,352 KB
testcase_07 AC 222 ms
5,436 KB
testcase_08 AC 221 ms
5,560 KB
testcase_09 AC 220 ms
5,440 KB
testcase_10 AC 222 ms
5,436 KB
testcase_11 AC 222 ms
5,524 KB
testcase_12 AC 223 ms
5,536 KB
testcase_13 AC 222 ms
5,360 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,384 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 164 ms
4,604 KB
testcase_25 AC 203 ms
4,868 KB
testcase_26 AC 86 ms
4,376 KB
testcase_27 AC 20 ms
4,380 KB
testcase_28 AC 190 ms
5,144 KB
testcase_29 AC 74 ms
4,376 KB
testcase_30 AC 188 ms
4,908 KB
testcase_31 AC 119 ms
4,380 KB
testcase_32 AC 75 ms
4,376 KB
testcase_33 AC 132 ms
4,380 KB
testcase_34 AC 152 ms
4,380 KB
testcase_35 AC 160 ms
4,564 KB
testcase_36 AC 150 ms
4,452 KB
testcase_37 AC 71 ms
4,380 KB
testcase_38 AC 168 ms
4,640 KB
testcase_39 AC 70 ms
4,380 KB
testcase_40 AC 92 ms
4,376 KB
testcase_41 AC 219 ms
5,240 KB
testcase_42 AC 113 ms
4,376 KB
testcase_43 AC 137 ms
4,408 KB
testcase_44 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N,Q;
long ans[1<<17];
main()
{
	cin>>N>>Q;
	vector<pair<int,int> >A(N+Q);
	long now=0,W=0;
	for(int i=0;i<N;i++)
	{
		cin>>A[i].first>>A[i].second;
		now+=(long)A[i].first*A[i].second;
		W-=A[i].second;
	}
	for(int i=0;i<Q;i++)
	{
		cin>>A[N+i].first;
		A[N+i].second=-i;
	}
	sort(A.begin(),A.end());
	int pre=0;
	for(pair<int,int>p:A)
	{
		int x=p.first;
		now+=W*(x-pre);
		pre=x;
		if(p.second>0)
		{
			W+=p.second*2;
		}
		else
		{
			ans[-p.second]=now;
		}
	}
	for(int i=0;i<Q;i++)cout<<ans[i]<<endl;
}
0