Submission #79727

#TimeUsernameProblemLanguageResultExecution timeMemory
79727KLPPRelativnost (COCI15_relativnost)C++14
42 / 140
4038 ms15524 KiB
#include<iostream> #include<algorithm> #include<vector> using namespace std; typedef long long int lld; #define MOD 10007 int n,c; void compute(lld a[],lld b[]){ lld DP[n+1][c+1]; for(int i=0;i<=n;i++){ for(int j=0;j<=c;j++)DP[i][j]=0; }DP[0][0]=1; for(int i=0;i<n;i++){ for(int j=0;j<=c;j++){ DP[i+1][j]+=DP[i][j]*b[i]; DP[i+1][j]%=MOD; DP[i+1][min(j+1,c)]+=DP[i][j]*a[i]; DP[i+1][min(j+1,c)]%=MOD; } } /*for(int i=0;i<=n;i++){ for(int j=0;j<=c;j++)cout<<DP[i][j]<<" "; cout<<endl; }*/ cout<<DP[n][c]<<endl; } int main(){ cin>>n>>c; lld a[n]; lld b[n]; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<n;i++)cin>>b[i]; int q; cin>>q; while(q--){ int x; cin>>x; x--; lld y,z; cin>>y>>z; a[x]=y; b[x]=z; compute(a,b); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...