結果

問題 No.877 Range ReLU Query
ユーザー tails
提出日時 2019-09-07 23:10:42
言語 cLay
(20241019-1)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 4,311 ms
コンパイル使用メモリ 190,996 KB
実行使用メモリ 25,088 KB
最終ジャッジ日時 2024-11-08 10:18:05
合計ジャッジ時間 7,637 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

segtree<ll> t,c;
pair<ll,pair<ll,pair<ll,ll>>> b[2d5];
ll n,q,bn,x,j,l,r,z[1d5];
{
	rd(n,q);
	t.walloc(n,1);
	c.walloc(n,1);
	rep(j,n)rd(x),b[bn++]={x,{j,{0,0}}};
	rep(j,q)rd(x,l,r,x),b[bn++]={x,{j,{l,r}}};
	sort(b,b+bn);
	for(;bn--;){
		x=b[bn].first;
		j=b[bn].second.first;
		l=b[bn].second.second.first;
		r=b[bn].second.second.second;
		if(l){
			z[j]=t.getSum(l-1,r)-c.getSum(l-1,r)*x;
		}else{
			t.add(j,j+1,x);
			c.change(j,j+1,1);
		}
	}
	wtLn(z(q));
}
0