# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
733570 |
2023-05-01T03:44:32 Z |
pcc |
Fire (JOI20_ho_t5) |
C++14 |
|
105 ms |
10924 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];
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&&brr[p]<=arr[i]&&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;
}
int32_t 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 |
212 KB |
Output is correct |
2 |
Correct |
4 ms |
340 KB |
Output is correct |
3 |
Correct |
4 ms |
340 KB |
Output is correct |
4 |
Correct |
5 ms |
340 KB |
Output is correct |
5 |
Correct |
4 ms |
340 KB |
Output is correct |
6 |
Correct |
4 ms |
348 KB |
Output is correct |
7 |
Correct |
3 ms |
340 KB |
Output is correct |
8 |
Correct |
4 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 |
4 ms |
340 KB |
Output is correct |
13 |
Correct |
7 ms |
348 KB |
Output is correct |
14 |
Correct |
7 ms |
340 KB |
Output is correct |
15 |
Correct |
7 ms |
340 KB |
Output is correct |
16 |
Correct |
7 ms |
340 KB |
Output is correct |
17 |
Correct |
7 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
344 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 |
344 KB |
Output is correct |
22 |
Correct |
5 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
292 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 |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
105 ms |
10736 KB |
Output is correct |
3 |
Correct |
103 ms |
10716 KB |
Output is correct |
4 |
Incorrect |
101 ms |
10924 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
104 ms |
9924 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
90 ms |
9036 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
4 ms |
340 KB |
Output is correct |
3 |
Correct |
4 ms |
340 KB |
Output is correct |
4 |
Correct |
5 ms |
340 KB |
Output is correct |
5 |
Correct |
4 ms |
340 KB |
Output is correct |
6 |
Correct |
4 ms |
348 KB |
Output is correct |
7 |
Correct |
3 ms |
340 KB |
Output is correct |
8 |
Correct |
4 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 |
4 ms |
340 KB |
Output is correct |
13 |
Correct |
7 ms |
348 KB |
Output is correct |
14 |
Correct |
7 ms |
340 KB |
Output is correct |
15 |
Correct |
7 ms |
340 KB |
Output is correct |
16 |
Correct |
7 ms |
340 KB |
Output is correct |
17 |
Correct |
7 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
344 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 |
344 KB |
Output is correct |
22 |
Correct |
5 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
292 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 |
105 ms |
10736 KB |
Output is correct |
34 |
Correct |
103 ms |
10716 KB |
Output is correct |
35 |
Incorrect |
101 ms |
10924 KB |
Output isn't correct |
36 |
Halted |
0 ms |
0 KB |
- |