#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
5 ms |
332 KB |
Output is correct |
3 |
Correct |
7 ms |
332 KB |
Output is correct |
4 |
Correct |
7 ms |
332 KB |
Output is correct |
5 |
Correct |
5 ms |
336 KB |
Output is correct |
6 |
Correct |
7 ms |
316 KB |
Output is correct |
7 |
Correct |
4 ms |
332 KB |
Output is correct |
8 |
Correct |
4 ms |
332 KB |
Output is correct |
9 |
Correct |
5 ms |
332 KB |
Output is correct |
10 |
Correct |
5 ms |
332 KB |
Output is correct |
11 |
Correct |
4 ms |
332 KB |
Output is correct |
12 |
Correct |
5 ms |
332 KB |
Output is correct |
13 |
Correct |
10 ms |
320 KB |
Output is correct |
14 |
Correct |
8 ms |
332 KB |
Output is correct |
15 |
Correct |
8 ms |
324 KB |
Output is correct |
16 |
Correct |
8 ms |
332 KB |
Output is correct |
17 |
Correct |
8 ms |
332 KB |
Output is correct |
18 |
Correct |
8 ms |
332 KB |
Output is correct |
19 |
Correct |
8 ms |
332 KB |
Output is correct |
20 |
Correct |
8 ms |
332 KB |
Output is correct |
21 |
Correct |
8 ms |
340 KB |
Output is correct |
22 |
Correct |
7 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
1075 ms |
5356 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
1096 ms |
5340 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1090 ms |
3916 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
5 ms |
332 KB |
Output is correct |
3 |
Correct |
7 ms |
332 KB |
Output is correct |
4 |
Correct |
7 ms |
332 KB |
Output is correct |
5 |
Correct |
5 ms |
336 KB |
Output is correct |
6 |
Correct |
7 ms |
316 KB |
Output is correct |
7 |
Correct |
4 ms |
332 KB |
Output is correct |
8 |
Correct |
4 ms |
332 KB |
Output is correct |
9 |
Correct |
5 ms |
332 KB |
Output is correct |
10 |
Correct |
5 ms |
332 KB |
Output is correct |
11 |
Correct |
4 ms |
332 KB |
Output is correct |
12 |
Correct |
5 ms |
332 KB |
Output is correct |
13 |
Correct |
10 ms |
320 KB |
Output is correct |
14 |
Correct |
8 ms |
332 KB |
Output is correct |
15 |
Correct |
8 ms |
324 KB |
Output is correct |
16 |
Correct |
8 ms |
332 KB |
Output is correct |
17 |
Correct |
8 ms |
332 KB |
Output is correct |
18 |
Correct |
8 ms |
332 KB |
Output is correct |
19 |
Correct |
8 ms |
332 KB |
Output is correct |
20 |
Correct |
8 ms |
332 KB |
Output is correct |
21 |
Correct |
8 ms |
340 KB |
Output is correct |
22 |
Correct |
7 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
33 |
Execution timed out |
1075 ms |
5356 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |