Submission #156139

# Submission time Handle Problem Language Result Execution time Memory
156139 2019-10-03T16:10:28 Z mdn2002 Relativnost (COCI15_relativnost) C++14
0 / 140
4000 ms 39932 KB
#include<bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
long long n,c,a[1005],b[1005],q,dp[1005][1005][5];
long long f(int x,int cal,int cl)
{
    if(x>=n)
    {
        if(cal>=c)return 1;
        else return 0;
    }
    if(dp[x][cal][cl]!=-1)return dp[x][cal][cl];
    long long num=0;
    if(cl==0)
    {
        num+=a[x]*f(x+1,cal+1,0);
        num%=10007;
        num+=a[x]*f(x+1,cal+1,1);
        num%=10007;
    }
    else
    {
        num+=b[x]*f(x+1,cal,0);
        num%=10007;
        num+=b[x]*f(x+1,cal,1);
        num%=10007;
    }
    return dp[x][cal][cl]=num;
}
int main()
{
    cin>>n>>c;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    cin>>q;
    for(int i=0;i<q;i++)
    {
        memset(dp,-1,sizeof dp);
        long long x,y,z;
        cin>>x>>y>>z;
        a[x-1]=y;
        b[x-1]=z;
        cout<<((f(0,0,1)+f(0,0,0))/2)%10007<<endl;
    }
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4081 ms 39932 KB Time limit exceeded
2 Execution timed out 4034 ms 39928 KB Time limit exceeded
3 Execution timed out 4075 ms 39932 KB Time limit exceeded
4 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 6 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 5 ms 248 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 5 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 6 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)