#include <iostream>
using namespace std;
int main()
{
int n,k,q;
cin >> n >> k;
int a[n];
for (int i=0;i<n;i++)
cin >> a[i];
cin >> q;
int type,p,l,r,m;
for (int i=0;i<q;i++)
{
cin >> type;
if (type==1)
{
cin >> p;
continue;
}
cin >> l >> r >> m;
l--,r--;
long long vk=0;
for (int j=l;j<l+m;j++)
vk+=a[j];
long long window_sum=vk;
int left=l,right=l+m;
while (right<=r)
{
window_sum+=a[right]-a[left];
vk+=window_sum;
left++;
right++;
}
cout << vk << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
304 KB |
Output is correct |
3 |
Correct |
6 ms |
212 KB |
Output is correct |
4 |
Correct |
11 ms |
308 KB |
Output is correct |
5 |
Correct |
17 ms |
340 KB |
Output is correct |
6 |
Correct |
29 ms |
376 KB |
Output is correct |
7 |
Correct |
33 ms |
364 KB |
Output is correct |
8 |
Correct |
41 ms |
340 KB |
Output is correct |
9 |
Correct |
66 ms |
404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
222 ms |
656 KB |
Output is correct |
2 |
Correct |
475 ms |
812 KB |
Output is correct |
3 |
Correct |
902 ms |
972 KB |
Output is correct |
4 |
Execution timed out |
2073 ms |
1344 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
22 ms |
720 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |