# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
70489 | leehosu01 | On grid (kriii2_O) | C++17 | 75 ms | 2812 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.
#include<bits/stdc++.h>
using namespace std;
long long MP[301][301],CR[301][301],BF[301][301],CG[302],BG[302],to;
int N,M;
int main()
{
scanf("%d%d",&N,&M);
int i,j,k;
for(i=1;i<=N;i++)
for(j=1;j<=M;j++)
BF[i][j]=-(1ll<<50),scanf("%lld",&MP[i][j]);
CG[M+1]=BG[M+1]=-(1ll<<50);
for(to=0,j=M;j;j--)BG[j]=BF[j][M]=to+=MP[N][j];
for(i=N-1;i;i--,swap(CG,BG),swap(CR,BF))
for(j=1;j<=M;j++)
for(to=0,CG[k=j]=-(1ll<<50);k<=M;k++)
CG[j]=max(CG[j],CR[j][k]=max(BF[j][k],BG[k+1])+(to+=MP[i][k]));
printf("%lld",BG[1]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |