Submission #733563

# Submission time Handle Problem Language Result Execution time Memory
733563 2023-05-01T03:34:10 Z pcc Fire (JOI20_ho_t5) C++14
1 / 100
105 ms 15048 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-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();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 3 ms 328 KB Output is correct
5 Correct 4 ms 340 KB Output is correct
6 Correct 4 ms 340 KB Output is correct
7 Correct 3 ms 340 KB Output is correct
8 Correct 4 ms 340 KB Output is correct
9 Correct 3 ms 328 KB Output is correct
10 Correct 4 ms 328 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 7 ms 336 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
15 Correct 6 ms 352 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 6 ms 336 KB Output is correct
18 Correct 6 ms 328 KB Output is correct
19 Correct 6 ms 340 KB Output is correct
20 Correct 6 ms 340 KB Output is correct
21 Correct 6 ms 340 KB Output is correct
22 Correct 6 ms 352 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 332 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 93 ms 14924 KB Output is correct
3 Correct 97 ms 14900 KB Output is correct
4 Incorrect 99 ms 15048 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Incorrect 105 ms 14060 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 84 ms 11608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 3 ms 328 KB Output is correct
5 Correct 4 ms 340 KB Output is correct
6 Correct 4 ms 340 KB Output is correct
7 Correct 3 ms 340 KB Output is correct
8 Correct 4 ms 340 KB Output is correct
9 Correct 3 ms 328 KB Output is correct
10 Correct 4 ms 328 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 7 ms 336 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
15 Correct 6 ms 352 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 6 ms 336 KB Output is correct
18 Correct 6 ms 328 KB Output is correct
19 Correct 6 ms 340 KB Output is correct
20 Correct 6 ms 340 KB Output is correct
21 Correct 6 ms 340 KB Output is correct
22 Correct 6 ms 352 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 332 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 328 KB Output is correct
33 Correct 93 ms 14924 KB Output is correct
34 Correct 97 ms 14900 KB Output is correct
35 Incorrect 99 ms 15048 KB Output isn't correct
36 Halted 0 ms 0 KB -