Submission #341961

# Submission time Handle Problem Language Result Execution time Memory
341961 2020-12-31T19:35:31 Z Hazem Maja (COCI18_maja) C++14
0 / 110
2000 ms 65540 KB
/*
ID: tmhazem1
LANG: C++14
TASK: pprime
*/

#include <bits/stdc++.h>
using namespace std;

#define S second
#define F first
#define LL long long

const int N = 104;


LL LINF = 100000000000000000;
LL INF = 1000000000;
int MOD = 1e9+7;

LL dp[N][N][N*N];
LL vals[N][N];

int main()
{
    // freopen("out.txt","w",stdout);
    int n,m,a,b,k;
    scanf("%d%d%d%d%d",&n,&m,&a,&b,&k);

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        scanf("%lld",&vals[i][j]),dp[i][j][0] = -INF;

    dp[a][b][0] = 0;
    for(int k1=1;k1<=k;k1++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
            dp[i][j][k1] = max({dp[i-1][j][k1-1],dp[i+1][j][k1-1],dp[i][j-1][k1-1],dp[i][j+1][k1-1]})+vals[i][j];

    printf("%lld\n",dp[a][b][k]);
}       

Compilation message

maja.cpp: In function 'int main()':
maja.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |     scanf("%d%d%d%d%d",&n,&m,&a,&b,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
maja.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |         scanf("%lld",&vals[i][j]),dp[i][j][0] = -INF;
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 3692 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 204 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2082 ms 46436 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 185 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 210 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 843 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 198 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -