# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
341965 | Hazem | Maja (COCI18_maja) | C++14 | 2075 ms | 620 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.
/*
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][2];
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]);
for(int i=0;i<=n+1;i++)
for(int j=0;j<=m+1;j++)
dp[i][j][0] = dp[i][j][1] = -LINF;
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&1] = max({dp[i-1][j][1-(k1&1)],dp[i+1][j][1-(1&k1)],dp[i][j-1][1-(1&k1)],dp[i][j+1][1-(1&k1)]})+vals[i][j];
printf("%lld\n",dp[a][b][0]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |