This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 n,q;
void calc(){
int l,r,t;
cin>>t>>l>>r;
l--,r--;
int tmp[n];
for(int i = 0;i<n;i++)tmp[i] = arr[i];
while(t--){
for(int i = n-2;i>=0;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 = 0;i<n;i++)cin>>arr[i];
while(q--)calc();
}
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |