#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int maxn=1e5+5;
int n,k,q;
long long a[maxn],b[32];
long long tree[4*maxn];
int ql,qr;
void make_tree(int v, int l, int r)
{
if(l==r)
{
tree[v]=a[r];
return;
}
int mid=(l+r)/2;
make_tree(v*2,l,mid);
make_tree(v*2+1,mid+1,r);
tree[v]=tree[v*2]+tree[v*2+1];
}
long long query(int v, int l, int r)
{
if(r<ql||l>qr||l>r) return 0;
if(l>=ql&&r<=qr) return tree[v];
int mid=(l+r)/2;
return query(v*2,l,mid)+query(v*2+1,mid+1,r);
}
void read()
{
cin >> n >> k;
for(int i=1;i<=n;i++)
{
cin >> a[i];
}
cin >> q;
make_tree(1,1,n);
int ty,l,r,m;
for(int i=1;i<=q;i++)
{
cin >> ty;
if(ty==1)
{
for(int j=1;j<=k;j++)
{
cin >> b[j];
}
}
else
{
cin >> l >> r >> m;
long long sum=0;
long long ch=0;
for(int i=1;i<m;i++)
{
ql=i;
qr=i;
ch=query(1,1,n);
sum+=(i*ch);
ql=n-i+1;
qr=n-i+1;
ch=query(1,1,n);
sum+=(i*ch);
}
ql=m;
qr=n-m+1;
ch=query(1,1,n);
sum+=(ch*m);
cout << sum << endl;
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
read();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2057 ms |
1364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2058 ms |
2364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |