#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned int long long ull;
using namespace std;
ll MOD = 1e4+7;
//global
int N, C;
vector<ll> A;
vector<ll> B;
vector<vector<ll>> dp;
ll sol(int index, ll sum){
if(index == N) return sum >= C;
if(dp[index][sum] != -1) return dp[index][sum];
dp[index][sum] = (A[index]%MOD) * sol(index+1, sum+1);
dp[index][sum] %= MOD;
dp[index][sum] += (B[index]%MOD) * sol(index+1, sum);
return dp[index][sum];
}
//classes
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//stop
cin >> N >> C;
A.resize(N);
B.resize(N);
for(ll& i: A) cin >> i;
for(ll& i: B) cin >> i;
dp.resize(N, vector<ll>(N,-1));
int Q;
cin >> Q;
while(Q--){
int index;
ll a, b;
cin >> index >> a >> b;
A[index-1] = a;
B[index-1] = b;
cout << sol(0, 0LL) << '\n';
dp.assign(N, vector<ll>(N,-1));
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4066 ms |
7504 KB |
Time limit exceeded |
2 |
Execution timed out |
4069 ms |
5756 KB |
Time limit exceeded |
3 |
Execution timed out |
4057 ms |
4476 KB |
Time limit exceeded |
4 |
Runtime error |
54 ms |
65536 KB |
Execution killed with signal 9 |
5 |
Runtime error |
60 ms |
65536 KB |
Execution killed with signal 9 |
6 |
Runtime error |
59 ms |
65536 KB |
Execution killed with signal 9 |
7 |
Runtime error |
63 ms |
65536 KB |
Execution killed with signal 9 |
8 |
Runtime error |
70 ms |
65536 KB |
Execution killed with signal 9 |
9 |
Runtime error |
63 ms |
65536 KB |
Execution killed with signal 9 |
10 |
Runtime error |
60 ms |
65536 KB |
Execution killed with signal 9 |