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