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;
vector<int> vec;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, q, t, l, r;
cin >> n >> q;
for(int i = 0; i < n; i++){
cin >> t;
vec.push_back(t);
}
for(int i = 0; i < q; i++){
cin >> t >> l >> r;
for(int j = n - 2; j >= 0; j--){
vec[j + 1] = max(vec[j + 1], vec[j]);
}
int sum = 0;
for(int j = l - 1; j < r; j++){
sum += vec[j];
}
cout << sum << endl;
}
}
# | 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... |