Submission #733583

# Submission time Handle Problem Language Result Execution time Memory
733583 2023-05-01T04:00:07 Z pcc Fire (JOI20_ho_t5) C++14
7 / 100
208 ms 23372 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define int ll
#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];
	//for(int i =1;i<=n;i++)cout<<tmp[i]<<' ';cout<<endl;
	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;
	multiset<int> st;
	for(int i = 1;i<=n;i++){
		st.insert(arr[i]);
		if(st.size()>t+1)st.erase(st.find(arr[i-t-1]));
		brr[i] = *st.rbegin();
	}
	for(int i = 1;i<=n;i++)modify(i,brr[i]);//cout<<brr[i]<<' ';cout<<endl;
	//for(int i = 1;i<=n;i++)cout<<brr[i]<<' ';cout<<endl;
	for(auto &i:req){
		cout<<getval(i.fs,i.sc)<<'\n';
	}
	return;
}
/*
14 1
326908579 2008726166 6331162 13968167 1029427745 1923822745 2842230206 1213122301 2675719680 327392163 13456315 65956481 1342328178 2252328063
2 1 14
*/

int32_t main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	while(t--)solve();
}

Compilation message

ho_t5.cpp: In function 'void solve()':
ho_t5.cpp:65:15: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   65 |   if(st.size()>t+1)st.erase(st.find(arr[i-t-1]));
      |      ~~~~~~~~~^~~~
ho_t5.cpp:61:5: warning: unused variable 'p' [-Wunused-variable]
   61 |  ll p = 0;
      |     ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 5 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 5 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 7 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 7 ms 348 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 348 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 177 ms 16632 KB Output is correct
3 Correct 170 ms 19464 KB Output is correct
4 Correct 191 ms 13604 KB Output is correct
5 Correct 186 ms 21652 KB Output is correct
6 Correct 189 ms 17664 KB Output is correct
7 Correct 181 ms 21360 KB Output is correct
8 Correct 200 ms 19436 KB Output is correct
9 Correct 173 ms 21092 KB Output is correct
10 Correct 194 ms 21836 KB Output is correct
11 Correct 181 ms 23372 KB Output is correct
12 Correct 177 ms 22832 KB Output is correct
13 Correct 208 ms 17296 KB Output is correct
14 Correct 166 ms 20468 KB Output is correct
15 Correct 207 ms 20264 KB Output is correct
16 Correct 156 ms 17856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 192 ms 14028 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 123 ms 12356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 5 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 5 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 7 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 7 ms 348 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 348 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 177 ms 16632 KB Output is correct
34 Correct 170 ms 19464 KB Output is correct
35 Correct 191 ms 13604 KB Output is correct
36 Correct 186 ms 21652 KB Output is correct
37 Correct 189 ms 17664 KB Output is correct
38 Correct 181 ms 21360 KB Output is correct
39 Correct 200 ms 19436 KB Output is correct
40 Correct 173 ms 21092 KB Output is correct
41 Correct 194 ms 21836 KB Output is correct
42 Correct 181 ms 23372 KB Output is correct
43 Correct 177 ms 22832 KB Output is correct
44 Correct 208 ms 17296 KB Output is correct
45 Correct 166 ms 20468 KB Output is correct
46 Correct 207 ms 20264 KB Output is correct
47 Correct 156 ms 17856 KB Output is correct
48 Incorrect 192 ms 14028 KB Output isn't correct
49 Halted 0 ms 0 KB -