Submission #1036078

#TimeUsernameProblemLanguageResultExecution timeMemory
1036078christinelynnAddk (eJOI21_addk)C++17
92 / 100
176 ms6740 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]; p1[i]=p1[i-1]+a[i]; p2[i]=p2[i-1]+p1[i]; } int q; cin>>q; while(q--){ int t; cin>>t; if(t==2){ int l,r,m; cin>>l>>r>>m; 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]; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...