답안 #733564

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
733564 2023-05-01T03:35:15 Z pcc Fire (JOI20_ho_t5) C++14
1 / 100
97 ms 9416 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define fs first
#define sc second

const int mxn = 2e5+10;
int arr[mxn];
int brr[mxn];
ll bit[mxn];
int n,q;

void modify(int p,ll v){
	for(;p<mxn;p+=p&-p)bit[p] += v;
	return;
}
ll getval(int s,int e){
	ll re = 0;
	for(;e>0;e-= e&-e)re += bit[e];
	s--;
	for(;s>0;s -= s&-s)re -= bit[s];
	return re;
}

void calc(){
	int l,r,t;
	cin>>t>>l>>r;
	int tmp[n+1];
	for(int i = 1;i<=n;i++)tmp[i] = arr[i];
	while(t--){
		for(int i = n-1;i>=1;i--){
			tmp[i+1] = max(tmp[i+1],tmp[i]);
		}
	}
	ll total = 0;
	for(int i = l;i<=r;i++)total += tmp[i];
	cout<<total<<'\n';
	return;
}

void solve(){
	cin>>n>>q;
	for(int i = 1;i<=n;i++)cin>>arr[i],brr[i] = arr[i];
	/*

   */
	if(n<=200&&q<=200){
		while(q--)calc();
		return;
	}
	ll t = 0;
	pll req[q];
	for(auto &i:req){
		cin>>t;
		cin>>i.fs>>i.sc;
	}
	ll p = 0;
	for(int i = 1;i<=n;i++){
		if(p<=i)p = i;
		while(p<n&&p+1-i<=t&&arr[p+1]<=arr[i]){
			p++;
			brr[p] = arr[i];
		}
		//cout<<i<<":"<<p<<endl;
	}
	for(int i = 1;i<=n;i++)modify(i,brr[i]);//cout<<brr[i]<<' ';cout<<endl;
	for(auto &i:req){
		cout<<getval(i.fs,i.sc)<<'\n';
	}
	return;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	while(t--)solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 4 ms 340 KB Output is correct
8 Correct 3 ms 340 KB Output is correct
9 Correct 4 ms 340 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
15 Correct 6 ms 340 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 6 ms 340 KB Output is correct
18 Correct 7 ms 340 KB Output is correct
19 Correct 6 ms 340 KB Output is correct
20 Correct 8 ms 340 KB Output is correct
21 Correct 7 ms 340 KB Output is correct
22 Correct 7 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 97 ms 9212 KB Output is correct
3 Correct 91 ms 9204 KB Output is correct
4 Incorrect 91 ms 9416 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 90 ms 8412 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 79 ms 7532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 4 ms 340 KB Output is correct
8 Correct 3 ms 340 KB Output is correct
9 Correct 4 ms 340 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
15 Correct 6 ms 340 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 6 ms 340 KB Output is correct
18 Correct 7 ms 340 KB Output is correct
19 Correct 6 ms 340 KB Output is correct
20 Correct 8 ms 340 KB Output is correct
21 Correct 7 ms 340 KB Output is correct
22 Correct 7 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 97 ms 9212 KB Output is correct
34 Correct 91 ms 9204 KB Output is correct
35 Incorrect 91 ms 9416 KB Output isn't correct
36 Halted 0 ms 0 KB -