結果

問題 No.1234 典型RMQ
ユーザー tails
提出日時 2020-09-24 16:11:59
言語 cLay
(20241019-1)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 3,075 ms
コンパイル使用メモリ 177,468 KB
実行使用メモリ 9,472 KB
最終ジャッジ日時 2024-11-09 02:25:05
合計ジャッジ時間 5,776 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

struct S{
	ll x,y;
	void operator=(int){}
	S operator+=(int v){
		y+=v;
		return *this;
	}
};

void segtree_pg_func(S&r,S&a,S&b){
	r={min(a.x,a.y+b.x),a.y+b.y};
}

ll n,a[2d5],q,k,l,r,c;
segtree_pg<S>t;
{
	rd(n,a(n),q);
	t.walloc(n+1);
	t.setN(n+1);
	t[1..n]={a[0..],0};
	t.build();
	rep(q){
		rd(k,l--,r,c);
		if(k==1){
			t.change(l,t[l]+=c);
			t.change(r,t[r]+=-c);
		}else{
			wt(t.get(0,l+1).y+t.get(l+1,r+1).x);
		}
	}
}
0