Submission #1113969

#TimeUsernameProblemLanguageResultExecution timeMemory
1113969jpfr12Relativnost (COCI15_relativnost)C++17
0 / 140
4062 ms65536 KiB
#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] * sol(index+1, sum+1); dp[index][sum] %= MOD; dp[index][sum] += B[index] * 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...