# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
476673 | 2021-09-28T05:34:08 Z | dzdzx | Addk (eJOI21_addk) | C++17 | 151 ms | 1532 KB |
#include<bits/stdc++.h> using namespace std; int main(){ int n,k; cin>>n>>k; int x[n+1]; for (int i=1;i<=n;i++){ cin>>x[i]; } long long f1[n+1]; long long f2[n+1]; f1[0]=0; f2[0]=0; for (int i=1;i<=n;i++){ f1[i]=f1[i-1]+x[i]; f2[i]=f2[i-1]+i*x[i]; } int q; cin>>q; int ans[10000]; int r=0; for (int i=0;i<q;i++){ int u; cin>>u; if (u==2){ int a,b,m; cin>>a>>b>>m; if(b-a+1>=2*m-1){ int s1 = (f2[a+m-1] - f2[a-1])-(f1[a+m-1] - f1[a-1])*(a-1); int s2 = (f1[b-m] - f1[a+m-1])*m; int s3 = (f1[b] - f1[b-m])*(b+1) - (f2[b] - f2[b-m]); cout<<s1+s2+s3<<endl; }else{ int s1 = (f2[b-m] - f2[a-1])-(f1[b-m] - f1[a-1])*(a-1); int s2 = (f1[a+m-1] - f1[b-m])*(b-a-m+2); int s3 = (f1[b] - f1[a+m-1])*(b+1) - (f2[b] - f2[a+m-1]); cout<<s1+s2+s3<<endl; } }else{ for (int j=0;j<k;j++){ int z; cin>>z; } } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 3 ms | 204 KB | Output is correct |
3 | Incorrect | 6 ms | 332 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 56 ms | 832 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 151 ms | 1532 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |