Submission #448781

# Submission time Handle Problem Language Result Execution time Memory
448781 2021-08-01T13:14:09 Z IvnF Relativnost (COCI15_relativnost) C++14
0 / 140
4000 ms 19868 KB
#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][c+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 Runtime error 3 ms 588 KB Execution killed with signal 11
2 Runtime error 2 ms 588 KB Execution killed with signal 11
3 Runtime error 2 ms 716 KB Execution killed with signal 11
4 Execution timed out 4050 ms 7244 KB Time limit exceeded
5 Execution timed out 4072 ms 15508 KB Time limit exceeded
6 Execution timed out 4062 ms 19868 KB Time limit exceeded
7 Execution timed out 4070 ms 11076 KB Time limit exceeded
8 Execution timed out 4070 ms 12740 KB Time limit exceeded
9 Execution timed out 4067 ms 11088 KB Time limit exceeded
10 Execution timed out 4059 ms 16580 KB Time limit exceeded