Submission #1113969

# Submission time Handle Problem Language Result Execution time Memory
1113969 2024-11-18T01:09:20 Z jpfr12 Relativnost (COCI15_relativnost) C++17
0 / 140
4000 ms 65536 KB
#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
1 Execution timed out 4058 ms 7536 KB Time limit exceeded
2 Execution timed out 4062 ms 5780 KB Time limit exceeded
3 Incorrect 3321 ms 4512 KB Output isn't correct
4 Runtime error 66 ms 65536 KB Execution killed with signal 9
5 Runtime error 69 ms 65536 KB Execution killed with signal 9
6 Runtime error 60 ms 65536 KB Execution killed with signal 9
7 Runtime error 55 ms 65536 KB Execution killed with signal 9
8 Runtime error 60 ms 65536 KB Execution killed with signal 9
9 Runtime error 61 ms 65536 KB Execution killed with signal 9
10 Runtime error 57 ms 65536 KB Execution killed with signal 9