# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
476194 | 2021-09-25T09:51:39 Z | dzdzx | Addk (eJOI21_addk) | C++17 | 2000 ms | 262324 KB |
#include<bits/stdc++.h> using namespace std; int main(){ int n,k; cin>>n>>k; int x[n]; for (int i=0;i<n;i++){ cin>>x[i]; } long long f1[n]; long long f2[n]; long long f3[n]; f1[0]=x[0]; f2[0]=x[0]; for (int i=1;i<n;i++){ f1[i]=f1[i-1]+x[i]; f2[i]=f2[i-1]+(i+1)*x[i]; } f3[n-1]=x[n-1]; for (int i=n-2;i>=0;i--){ f3[i]=f3[i+1]+(n-i)*x[i]; } int q; cin>>q; for (int i=0;i<q;i++){ int u; cin>>u; if (u==2){ int a,b,m; cin>>a>>b>>m;a--;b--; if (b-a+1>=(m-1)*2){ int sum=0; int s1=0; int s2=0; int s3=0; s1=f2[m+a-2]-f2[a-1]; s1-=a*(f1[m+a-2]-f1[a-1]); s2=m*(f1[b-m+1]-f1[m+a-2]); s3=f3[b-m+2]-f3[b+1]; s3-=(n-b-1)*(f1[b]-f1[b-m+1]); cout<<s1+s2+s3<<endl;; }else{ int sum=0; int s1=0; int s2=0; int s3=0; int num=(b-a+1)-m; s1=f2[b-m]-f2[a-1]; s1-=a*(f1[b-m]-f1[a-1]); s2=(num+1)*(f1[a+m-1]-f1[b-m]); s3=f3[a+m]-f3[b+1]; cout<<s3<<endl; s3-=(n-b-1)*(f1[b]-f1[a+m-1]); cout<<f3[a+m]<<" "<<f3[b+1]<<endl;; for (int i=0;i<n;i++)cout<<f3[i]<<" ";cout<<endl; cout<<s1+s2+s3<<endl;; } }else{ for (int j=0;j<k;j++){ int z; cin>>z; } } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2070 ms | 262324 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2081 ms | 253796 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |