Submission #600187

#TimeUsernameProblemLanguageResultExecution timeMemory
600187Jovan26Addk (eJOI21_addk)C++14
0 / 100
390 ms1484 KiB
#include<bits/stdc++.h> using namespace std; int main(){ long long n,k; cin>>n>>k; long long a[n]; for(long long i=0;i<n;i++){ cin>>a[i]; } long long q; cin>>q; long long sums[q]; long long u = 0; if(k==1){ for(long long i=0;i<q;i++){ long long x; cin>>x; if(x==1){ long long y; cin>>y; continue; } else{ long long l,r,m; cin>>l>>r>>m; long long s = 0; long long d = r-l+1; for(long long j=l-1; j<r; j++){ long long p = j-l+2; if(p<m && !(d-p+1<m)){ s+=a[j]*p; } else if(d-p+1<m && !(p<m)){ s+=a[j]*(d-p+1); } else if(p<m && d-p+1<m){ s+=min(a[j]*p,a[j]*(m-(d-p+1))); } else{ s+=a[j]*m; } } sums[u] = s; u++; } } } for(long long i=0;i<u-1;i++){ cout<<sums[i]<<endl; } cout<<sums[u-1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...