Submission #10104

#TimeUsernameProblemLanguageResultExecution timeMemory
10104gs14004On grid (kriii2_O)C++98
1 / 4
1000 ms2148 KiB
#include <cstdio> #include <algorithm> using namespace std; int a[301][301]; int sum[301][301]; int dp[301][301]; int r,c; struct rmq{ int lim, tree[1025]; void init(int n){ } }; void prep(){ scanf("%d %d",&r,&c); for (int i=1; i<=r; i++) { for (int j=1; j<=c; j++) { scanf("%d",&a[i][j]); } } for (int i=1; i<=r; i++) { for (int j=1; j<=c; j++) { sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + a[i][j]; } } } int main(){ prep(); for (int i=1; i<=r; i++) { for (int j=1; j<=c; j++) { for (int k=1; k<i; k++) { for (int l=1; l<j; l++) { dp[i][j] = max(dp[i][j], dp[k][l] - sum[k][j] - sum[i][l]); } } dp[i][j] += 2*sum[i][j]; } } printf("%d",dp[r][c]-sum[r][c]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...