Submission #1040240

#TimeUsernameProblemLanguageResultExecution timeMemory
1040240biserailievaAddk (eJOI21_addk)C++14
36 / 100
2079 ms4252 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int main(){ int n,k; cin>>n>>k; ll a[n+1],p1[n+1],p2[n+1]; a[0]=p1[0]=p2[0]=0; 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; for(int i=1;i<=n;i++){ p1[i]=p1[i-1]+a[i]; p2[i]=p2[i-1]+p1[i]; } ll ans=p2[r]-p2[l+m-2]-p2[r-m]; if(l>1)ans+=p2[l-2]; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...