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;
typedef long long int ll;
typedef long double ld;
int main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int n, q, k;
cin >> n >> k;
ll a[n + 1];
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
cin >> q;
int type, l, r, m;
ll sum;
int p1;
while (q--)
{
cin >> type;
if (type == 1)
{
for (int i = 0; i < k; i++)
{
cin >> type;
}
continue;
}
cin >> l >> r >> m;
l--;
r--;
sum = 0;
p1 = 1;
int mm = min(r - l + 1 - m + 1, m);
for (int i = l; i < (l + r) / 2; i++)
{
sum += a[i] * min(p1, mm);
p1++;
}
p1 = 1;
for (int i = r; i >= (l + r) / 2; i--)
{
sum += a[i] * min(p1, mm);
p1++;
}
cout << sum << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |