# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
164156 | beso123 | Relativnost (COCI15_relativnost) | C++14 | 163 ms | 25144 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,a[100005],b[100005],dp[100005][30];
main(){
//freopen("test.in","r",stdin);
cin>>n>>m;
for(int k=1;k<=n;k++)
cin>>a[k];
for(int k=1;k<=n;k++)
cin>>b[k];
int pas=1;
for(int k=1;k<=n;k++)
pas*=(a[k]+b[k]);
int sum=b[1];
dp[1][0]=b[1];
dp[1][1]=a[1];
for(int k=2;k<=n;k++){
sum*=b[k];
dp[k][0]=sum;
for(int i=1;i<m;i++){
if(k<i)
continue;
dp[k][i]=(b[k]*dp[k-1][i])+(a[k]*dp[k-1][i-1]);
}
}
int jam=0;
for(int i=0;i<m;i++)
jam+=dp[n][i];
cout<<pas-jam;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |