Submission #1040240

# Submission time Handle Problem Language Result Execution time Memory
1040240 2024-07-31T19:39:20 Z biserailieva Addk (eJOI21_addk) C++14
36 / 100
2000 ms 4252 KB
#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 time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 6 ms 348 KB Output is correct
4 Correct 11 ms 600 KB Output is correct
5 Correct 18 ms 640 KB Output is correct
6 Correct 25 ms 660 KB Output is correct
7 Correct 34 ms 724 KB Output is correct
8 Correct 46 ms 780 KB Output is correct
9 Correct 88 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 342 ms 1532 KB Output is correct
2 Correct 720 ms 2128 KB Output is correct
3 Correct 1285 ms 2896 KB Output is correct
4 Execution timed out 2079 ms 3920 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1369 ms 3924 KB Output is correct
2 Execution timed out 2035 ms 4252 KB Time limit exceeded
3 Halted 0 ms 0 KB -