#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Q{
int l, r, time, index;
};
bool comp(const Q &q1, const Q &q2){
return q1.time<q2.time;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, q;
cin>>n>>q;
vector<int> vect(n);
for (int i=0;i<n;i++) cin>>vect[i];
vector<Q> qv(q);
for (int i=0;i<q;i++){
cin>>qv[i].time>>qv[i].l>>qv[i].r;
qv[i].index=i;
}
sort(qv.begin(), qv.end(), comp);
int t=0;
vector<int> out(q);
for (Q qe:qv){
int tDiff=qe.time-t;
t=qe.time;
for (int i=0;i<tDiff;i++){
for (int j=n-2;j>=0;j--){
if (vect[j]>vect[j+1]) vect[j+1]=vect[j];
}
}
for (int i=qe.l-1;i<=qe.r-1;i++) out[qe.index]+=vect[i];
}
for (int x:out) cout<<x<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Execution timed out |
1050 ms |
6984 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Execution timed out |
1056 ms |
5104 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1047 ms |
6728 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |