結果

問題 No.1441 MErGe
ユーザー 沙耶花沙耶花
提出日時 2020-11-26 17:52:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,494 bytes
コンパイル時間 2,405 ms
コンパイル使用メモリ 204,612 KB
実行使用メモリ 18,624 KB
最終ジャッジ日時 2024-04-20 10:30:30
合計ジャッジ時間 13,403 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 8 ms
5,376 KB
testcase_04 AC 9 ms
5,376 KB
testcase_05 AC 34 ms
5,376 KB
testcase_06 AC 36 ms
5,376 KB
testcase_07 AC 35 ms
5,376 KB
testcase_08 AC 454 ms
7,040 KB
testcase_09 AC 447 ms
7,040 KB
testcase_10 AC 790 ms
6,912 KB
testcase_11 AC 699 ms
5,376 KB
testcase_12 AC 796 ms
7,040 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
using namespace atcoder;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

pair<long long,int> op(pair<long long,int> a,pair<long long,int> b){
	a.first += b.first;
	a.second += b.second;
	return a;
}

pair<long long,int> e(){
	return make_pair(0LL,0);
}

pair<long long,int> mapping(pair<long long,int> a,pair<long long,int> b){
	if(a.second==-1)return b;
	return a;
}

pair<long long,int> composition(pair<long long,int> a,pair<long long,int> b){
	if(a.second==-1)return b;
	if(b.second==-1)return a;
	return a;
}

pair<long long,int> id(){
	return make_pair(0LL,-1);
}

int main(){
	
	int N,Q;
	cin>>N>>Q;
	
	vector<pair<long long,int>> A(N);
	rep(i,N){
		cin>>A[i].first;
		A[i].second = 1;
	}
	
	lazy_segtree<pair<long long,int>,op,e,pair<long long,int>,mapping,composition,id> seg(A);
	
	rep(i,Q){
		int T,l,r;
		cin>>T>>l>>r;
		
		int ok = N,ng = -1;
		while(ok-ng>1){
			int mid = (ok+ng)/2;
			if(seg.prod(0,mid).second >= r)ok = mid;
			else ng = mid;
		}
		r = ok;
		
		ok = N,ng = -1;
		while(ok-ng>1){
			int mid = (ok+ng)/2;
			if(seg.prod(0,mid).second >= l-1)ok = mid;
			else ng = mid;
		}
		l = ok;
		if(T==1){
			long long S = seg.prod(l,r).first;
			seg.apply(l,r,e());
			seg.set(l,make_pair(S,1));
		}
		else{
			cout<<seg.prod(l,r).first<<endl;
		}
		
	}
	
    return 0;
}
0