Submission #159956

# Submission time Handle Problem Language Result Execution time Memory
159956 2019-10-25T14:21:32 Z mdn2002 Mobitel (COCI19_mobitel) C++14
26 / 130
505 ms 2916 KB
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
long long r,c,n,a[353][353],dp[353][353],dp1[353][353];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>r>>c>>n;
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            cin>>a[i][j];
        }
    }
    dp[0][min(a[0][0],n)]=1;
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            if(i==0&&j==0)continue;
            for(int z=n;z>=0;z--)
            {
                long long x=z*a[i][j];
                if(dp1[j][z])dp[j][min(x,n)]+=dp1[j][z];
                if(dp[j-1][z]&&j!=0)dp[j][min(x,n)]+=dp[j-1][z];
                dp[j][min(x,n)]%=mod;
            }
        }
        for(int j=0;j<c;j++)
        {
            for(int z=0;z<=n;z++)
            {
                dp1[j][z]=dp[j][z];
                dp[j][z]=0;
            }
        }
    }
    cout<<dp1[c-1][n];
}
# Verdict Execution time Memory Grader output
1 Correct 469 ms 2808 KB Output is correct
2 Correct 505 ms 2916 KB Output is correct
3 Runtime error 4 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 4 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 4 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 4 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 3 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 7 ms 1784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 11 ms 2168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 12 ms 2168 KB Execution killed with signal 11 (could be triggered by violating memory limits)