結果

問題 No.2065 Sum of Min
ユーザー tailstails
提出日時 2022-09-02 23:10:02
言語 cLay
(20240104-1)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 5,650 ms
コンパイル使用メモリ 219,452 KB
実行使用メモリ 17,616 KB
最終ジャッジ日時 2023-08-10 05:33:04
合計ジャッジ時間 9,402 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 29 ms
17,520 KB
testcase_05 AC 30 ms
17,524 KB
testcase_06 AC 41 ms
17,264 KB
testcase_07 AC 31 ms
16,860 KB
testcase_08 AC 44 ms
17,600 KB
testcase_09 AC 44 ms
17,564 KB
testcase_10 AC 43 ms
17,536 KB
testcase_11 AC 41 ms
17,596 KB
testcase_12 AC 48 ms
17,524 KB
testcase_13 AC 49 ms
17,520 KB
testcase_14 AC 47 ms
17,536 KB
testcase_15 AC 46 ms
17,524 KB
testcase_16 AC 49 ms
17,532 KB
testcase_17 AC 49 ms
17,548 KB
testcase_18 AC 46 ms
17,540 KB
testcase_19 AC 48 ms
17,536 KB
testcase_20 AC 47 ms
17,612 KB
testcase_21 AC 48 ms
17,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ll@n,@q,@a[n],b[],l[q],r[],x[],y[],z[];
sortA_index(n,a,b);
fenwick<ll>f,g;
f.malloc(n,1);
g.malloc(n,1);
rep(j,n){
	f.add(b[j],a[j]);
}
rd((l,r,x)(q));
sortA_index(q,x,l,r,y);
ll c=n;
rrep(i,q){
	while(c&&a[c-1]>x[i]){
		--c;
		f.add(b[c],-a[c]);
		g.add(b[c],1);
	}
	z[y[i]]=f.range(l[i]-1,r[i]-1)+g.range(l[i]-1,r[i]-1)*x[i];
}
wtLn(z(q));
0