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;
using i64 = int64_t;
vector<vector<i64>> pre;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
i64 N, Q;
cin >> N >> Q;
vector<i64> district(N);
for (i64 i = 0; i < N; i++)
{
cin >> district[i];
}
pre.resize(N + 1);
pre[0] = district;
for (i64 i = 1; i <= N; i++)
{
pre[i].resize(N);
for (i64 k = 0; k < N; k++)
{
pre[i][k] = pre[i - 1][k];
if (k > 0) pre[i][k] = max(pre[i - 1][k - 1], pre[i][k]);
}
}
for (i64 i = 0; i < Q; i++)
{
i64 t, r, l, suma = 0;
cin >> t >> r >> l;
for (i64 k = r - 1; k < l; k++)
{
//cout << k << " : " << pre[t][k] << "\n";
suma += pre[t][k];
}
cout << suma << "\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... |