Submission #448795

# Submission time Handle Problem Language Result Execution time Memory
448795 2021-08-01T13:51:28 Z IvnF Relativnost (COCI15_relativnost) C++17
0 / 140
4000 ms 18624 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];
	memset(dp, 0, sizeof dp);
	for(int i=1;i<=n;++i){
		cin >> a[i];
	}
	for(int i=1;i<=n;++i){
		cin >> b[i];
	}
	dp[0][0]=1;
	for(int i=1;i<=n;++i){
		for(int j=0;j<=c;++j){
			dp[i][j]=(a[i]*dp[i-1][max(0, j-1)])%mod;
			dp[i][j]+=(b[i]*dp[i-1][j])%mod;
		}
	}
	cin >> q;
	while(q--){
		ll idx, ai, bi; cin >> idx >> ai >> bi;
		a[idx]=ai;
		b[idx]=bi;
		for(int i=idx;i<=n;++i){
			for(int j=0;j<=c;++j){
				dp[i][j]=(a[i]*dp[i-1][max(0, j-1)])%mod;
				dp[i][j]+=(b[i]*dp[i-1][j])%mod;
			}
		}
		cout << dp[n][c] << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 332 KB Output isn't correct
2 Incorrect 39 ms 332 KB Output isn't correct
3 Incorrect 50 ms 460 KB Output isn't correct
4 Execution timed out 4077 ms 6532 KB Time limit exceeded
5 Execution timed out 4064 ms 14144 KB Time limit exceeded
6 Execution timed out 4051 ms 18624 KB Time limit exceeded
7 Execution timed out 4027 ms 10320 KB Time limit exceeded
8 Execution timed out 4086 ms 11576 KB Time limit exceeded
9 Execution timed out 4097 ms 10084 KB Time limit exceeded
10 Execution timed out 4086 ms 15712 KB Time limit exceeded