#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[1005][1005], a[1005], b[1005];
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]%mod;
}
for(int i=1;i<=n;++i){
for(int j=1;j<=n;++j){
dp[i][j]=((b[i]*dp[i-1][j])%mod+(a[i]*dp[i-1][j-1])%mod)%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 |
Execution timed out |
4046 ms |
8208 KB |
Time limit exceeded |
2 |
Execution timed out |
4051 ms |
8208 KB |
Time limit exceeded |
3 |
Incorrect |
3965 ms |
8208 KB |
Output isn't correct |
4 |
Runtime error |
28 ms |
16452 KB |
Execution killed with signal 11 |
5 |
Runtime error |
41 ms |
16456 KB |
Execution killed with signal 11 |
6 |
Runtime error |
40 ms |
16404 KB |
Execution killed with signal 11 |
7 |
Runtime error |
35 ms |
16480 KB |
Execution killed with signal 11 |
8 |
Runtime error |
38 ms |
16408 KB |
Execution killed with signal 11 |
9 |
Runtime error |
33 ms |
16416 KB |
Execution killed with signal 11 |
10 |
Runtime error |
31 ms |
16412 KB |
Execution killed with signal 11 |