#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ull unsigned long long
#define fi first
#define se second
#define ld long double
const ll mod=10007;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n, c, q;
cin >> n >> c;
ll dp[n+5][n+5], a[n+5], b[n+5];
for(int i=1;i<=n;++i){
cin >> a[i];
}
for(int i=1;i<=n;++i){
cin >> b[i];
}
cin >> q;
while(q--){
ll idx, ai, bi; cin >> idx >> ai >> bi;
a[idx]=ai;
b[idx]=bi;
memset(dp, 0, sizeof dp);
dp[0][0]=1;
for(int i=1;i<=n;++i){
dp[i][0]=b[i];
}
for(int i=1;i<=n;++i){
for(int j=1;j<=n;++j){
dp[i][j]=(b[i]*dp[i-1][j]+a[i]*dp[i-1][j-1])%mod;
}
}
ll ans=0;
for(int j=c;j<=n;++j){
ans+=dp[n][j];
ans%=mod;
}
cout << ans << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3093 ms |
7344 KB |
Output isn't correct |
2 |
Incorrect |
2781 ms |
5580 KB |
Output isn't correct |
3 |
Incorrect |
1505 ms |
4300 KB |
Output isn't correct |
4 |
Runtime error |
37 ms |
65540 KB |
Execution killed with signal 9 |
5 |
Runtime error |
33 ms |
65540 KB |
Execution killed with signal 9 |
6 |
Runtime error |
36 ms |
65540 KB |
Execution killed with signal 9 |
7 |
Runtime error |
37 ms |
65540 KB |
Execution killed with signal 9 |
8 |
Runtime error |
36 ms |
65540 KB |
Execution killed with signal 9 |
9 |
Runtime error |
36 ms |
65540 KB |
Execution killed with signal 9 |
10 |
Runtime error |
39 ms |
65540 KB |
Execution killed with signal 9 |