結果

問題 No.1012 荷物収集
ユーザー otamay6otamay6
提出日時 2019-11-27 11:07:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 994 bytes
コンパイル時間 1,672 ms
コンパイル使用メモリ 165,512 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-04-22 13:05:36
合計ジャッジ時間 9,955 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 219 ms
6,272 KB
testcase_05 AC 214 ms
6,400 KB
testcase_06 AC 214 ms
6,528 KB
testcase_07 AC 213 ms
6,400 KB
testcase_08 AC 241 ms
6,400 KB
testcase_09 AC 214 ms
6,400 KB
testcase_10 AC 213 ms
6,400 KB
testcase_11 AC 216 ms
6,400 KB
testcase_12 AC 216 ms
6,528 KB
testcase_13 AC 216 ms
6,528 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include"bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
int roundup(int a,int b){return	(a-1)/b+1;}

signed main(){
	int N,Q;
	cin>>N>>Q;
	vector<ll> x(N),w(N),X(Q);
	rep(i,N) cin>>x[i]>>w[i];
	rep(i,Q) cin>>X[i];
	vector<ll> S(N+1);
	ll res=0;
	rep(i,N){
		S[i+1]=S[i]+w[i];
		res+=llabs(X[0]-x[i])*w[i];
	}
	cout<<res<<endl;
	int j=0;
	rep(i,1,Q){
		int l=j;
		while(j<N&&X[i]>x[j]){
			res-=llabs(x[j]-X[i-1])*w[j];
			res+=(X[i]-x[j])*w[j];
			j++;
		}
		int r=j;
		res+=(X[i]-X[i-1])*(S[l]-(S[N]-S[r]));
		cout<<res<<endl;
	}
}
0