#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 |
1 |
Incorrect |
67 ms |
632 KB |
Output isn't correct |
2 |
Incorrect |
101 ms |
788 KB |
Output isn't correct |
3 |
Incorrect |
145 ms |
912 KB |
Output isn't correct |
4 |
Execution timed out |
4086 ms |
6200 KB |
Time limit exceeded |
5 |
Execution timed out |
4009 ms |
14688 KB |
Time limit exceeded |
6 |
Execution timed out |
4099 ms |
20816 KB |
Time limit exceeded |
7 |
Execution timed out |
4006 ms |
20816 KB |
Time limit exceeded |
8 |
Execution timed out |
4014 ms |
20816 KB |
Time limit exceeded |
9 |
Execution timed out |
4094 ms |
20816 KB |
Time limit exceeded |
10 |
Execution timed out |
4097 ms |
25064 KB |
Time limit exceeded |