Submission #8365

#TimeUsernameProblemLanguageResultExecution timeMemory
8365cki86201On grid (kriii2_O)C++98
0 / 4
0 ms1804 KiB
#include<stdio.h> #include<algorithm> //O(R^2 * C^2) int d[303][303]; int p[303][303]; #define Get(a,b,c,d) (p[c][d]-p[a-1][d]-p[c][b-1]+p[a-1][b-1]) int main(){ int r,c,i,j; scanf("%d%d",&r,&c); for(i=1;i<=r;i++)for(j=1;j<=c;j++)scanf("%d",p[i]+j); for(i=1;i<=r;i++)for(j=1;j<=c;j++)p[i][j] += p[i][j-1] + p[i-1][j] - p[i-1][j-1]; for(i=1;i<=r;i++)for(j=1;j<=c;j++){ int k, l; for(k=i;k;k--)for(l=j;l;l--) d[i][j] = std::max(d[i][j], d[k-1][l-1] + Get(k, l, i, j)); } printf("%d",d[r][c]); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...