結果

問題 No.2065 Sum of Min
ユーザー tailstails
提出日時 2022-09-02 23:10:02
言語 cLay
(20240104-1)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 6,947 ms
コンパイル使用メモリ 223,372 KB
実行使用メモリ 15,872 KB
最終ジャッジ日時 2024-04-27 22:50:32
合計ジャッジ時間 8,772 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 35 ms
15,616 KB
testcase_05 AC 32 ms
15,872 KB
testcase_06 AC 39 ms
15,360 KB
testcase_07 AC 31 ms
14,976 KB
testcase_08 AC 48 ms
15,744 KB
testcase_09 AC 51 ms
15,616 KB
testcase_10 AC 49 ms
15,616 KB
testcase_11 AC 45 ms
15,616 KB
testcase_12 AC 45 ms
15,616 KB
testcase_13 AC 47 ms
15,744 KB
testcase_14 AC 45 ms
15,488 KB
testcase_15 AC 45 ms
15,872 KB
testcase_16 AC 45 ms
15,744 KB
testcase_17 AC 45 ms
15,616 KB
testcase_18 AC 45 ms
15,616 KB
testcase_19 AC 46 ms
15,744 KB
testcase_20 AC 47 ms
15,616 KB
testcase_21 AC 46 ms
15,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