Submission #1036089

#TimeUsernameProblemLanguageResultExecution timeMemory
1036089christinelynnAddk (eJOI21_addk)C++17
0 / 100
1547 ms3076 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...