#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int n,k;
cin>>n>>k;
ll a[n+1];
for(int i=1;i<=n;i++)cin>>a[i];
int q;
cin>>q;
while(q--){
int t;
cin>>t;
if(t==2){
int l,r,m;
cin>>l>>r>>m;
ll ans=0;
for(int i=l;i<=r;i++){
ll mt=min(m,min(i-l+1,r-i+1));
ans+=mt*a[i];
}
cout<<ans<<'\n';
}else{
int x[k];
for(int i=0;i<k;i++)cin>>x[i];
int p=a[x[0]];
for(int i=0;i<k-1;i++)a[x[i]]=a[x[i+1]];
a[x[k-1]]=p;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
365 ms |
1224 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1547 ms |
3076 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |