# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
79727 | KLPP | Relativnost (COCI15_relativnost) | C++14 | 4038 ms | 15524 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<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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |