結果

問題 No.877 Range ReLU Query
ユーザー tailstails
提出日時 2019-09-07 23:10:42
言語 cLay
(20240104-1)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 4,700 ms
コンパイル使用メモリ 191,956 KB
実行使用メモリ 30,448 KB
最終ジャッジ日時 2024-04-25 22:12:54
合計ジャッジ時間 7,897 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 3 ms
7,640 KB
testcase_02 AC 3 ms
7,768 KB
testcase_03 AC 3 ms
7,628 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 3 ms
9,548 KB
testcase_06 AC 3 ms
7,648 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 4 ms
9,548 KB
testcase_09 AC 3 ms
7,508 KB
testcase_10 AC 2 ms
6,948 KB
testcase_11 AC 207 ms
28,180 KB
testcase_12 AC 170 ms
28,504 KB
testcase_13 AC 130 ms
19,856 KB
testcase_14 AC 124 ms
20,044 KB
testcase_15 AC 218 ms
27,948 KB
testcase_16 AC 209 ms
30,184 KB
testcase_17 AC 216 ms
30,448 KB
testcase_18 AC 212 ms
28,640 KB
testcase_19 AC 194 ms
28,360 KB
testcase_20 AC 212 ms
28,032 KB
権限があれば一括ダウンロードができます

ソースコード

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