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 <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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |