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;
#define int long long
#define pb push_back
#define sz(x) x.size()
#define nl '\n'
#define F first
#define S second
const int N = 1e6 + 1;
const int inf = 1e18;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, k, q;
cin >>n >>k;
int a[n + 1];
for( int i = 1; i <= n; ++i )
cin >>a[i];
cin >>q;
while( q-- )
{
int t, L, R, m, x;
cin >> t;
if (t == 1)
{
cin >>x;
continue;
}
else
{
cin >>L >>R >>m;
int sum = 0, res = 0;
for( int l = L, r = L; r <= R; ++r )
{
sum += a[r];
while( r - l + 1 > m )
{
sum -= a[l];
++l;
}
if( r - l + 1 == m )
res += sum;
}
cout <<res <<nl;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |