# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1113969 | jpfr12 | Relativnost (COCI15_relativnost) | C++17 | 4062 ms | 65536 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |