結果

問題 No.1099 Range Square Sum
ユーザー tailstails
提出日時 2020-09-25 17:44:27
言語 cLay
(20240104-1)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 479 bytes
コンパイル時間 2,557 ms
コンパイル使用メモリ 174,284 KB
実行使用メモリ 20,812 KB
最終ジャッジ日時 2023-09-19 01:23:57
合計ジャッジ時間 5,155 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 56 ms
20,600 KB
testcase_22 AC 57 ms
20,604 KB
testcase_23 AC 55 ms
20,628 KB
testcase_24 AC 57 ms
20,548 KB
testcase_25 AC 57 ms
20,812 KB
testcase_26 AC 34 ms
20,648 KB
testcase_27 AC 34 ms
20,552 KB
testcase_28 AC 34 ms
20,608 KB
testcase_29 AC 34 ms
20,652 KB
testcase_30 AC 35 ms
20,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

struct V{
	ll n,s,t,a;
};

inline void segtree_pg_func(V&r,V a,V b){
	r={
		a.n+b.n,
		a.s+a.a*b.n+b.s,
		a.t+b.t+a.a*(2b.s+a.a*b.n),
		a.a+b.a,
	};
}

segtree_pg<V>t;

inline void add(int i,ll a){
	t[i].a+=a;
	t.build(i+t.N);
}

{
	ll n,a;
	rd(n);
	t.walloc(n+1);
	t.setN(n+1,0,0);
	rep(i,n)rd(a),t[i+1]={1,a,a*a,0};
	t.build();
	rd(n);
	rep(n){
		ll x,l,r;
		rd(x,l,r++);
		if(x==1){
			rd(x);
			add(l-1,x);
			add(r-1,-x);
		}else{
			wt(t.get(0,r).t-t.get(0,l).t);
		}
	}
}
0