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>
#define F first
#define S second
#define ll long long
using namespace std;
typedef pair<long long,long long> ii;
const int N = 2e5+5;
ll n,q;
ll a[N],b[N];
int main()
{
cin.tie(0); ios_base::sync_with_stdio(0);
cin >> n >> q;
for (int i=1;i<=n;i++)
cin >> a[i];
while (q--) {
int x,l,r;
cin >> x >> l >> r;
for (int i=1;i<=n;i++) b[i] = 0;
for (int i=1;i<=n;i++) for (int j=0;j<=x;j++) {
if (i+j<=n) b[i+j] = max(b[i+j],a[i]);
}
ll s = 0;
for (int i=l;i<=r;i++) s += b[i];
cout << s << "\n";
}
return 0;
}
# | 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... |