#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]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2148 KB |
Output is correct |
2 |
Correct |
0 ms |
2148 KB |
Output is correct |
3 |
Correct |
0 ms |
2148 KB |
Output is correct |
4 |
Correct |
0 ms |
2148 KB |
Output is correct |
5 |
Correct |
0 ms |
2148 KB |
Output is correct |
6 |
Correct |
0 ms |
2148 KB |
Output is correct |
7 |
Correct |
0 ms |
2148 KB |
Output is correct |
8 |
Correct |
0 ms |
2148 KB |
Output is correct |
9 |
Correct |
0 ms |
2148 KB |
Output is correct |
10 |
Correct |
0 ms |
2148 KB |
Output is correct |
11 |
Correct |
0 ms |
2148 KB |
Output is correct |
12 |
Correct |
0 ms |
2148 KB |
Output is correct |
13 |
Correct |
0 ms |
2148 KB |
Output is correct |
14 |
Correct |
0 ms |
2148 KB |
Output is correct |
15 |
Correct |
0 ms |
2148 KB |
Output is correct |
16 |
Correct |
0 ms |
2148 KB |
Output is correct |
17 |
Correct |
0 ms |
2148 KB |
Output is correct |
18 |
Correct |
0 ms |
2148 KB |
Output is correct |
19 |
Correct |
0 ms |
2148 KB |
Output is correct |
20 |
Correct |
0 ms |
2148 KB |
Output is correct |
21 |
Correct |
0 ms |
2148 KB |
Output is correct |
22 |
Correct |
0 ms |
2148 KB |
Output is correct |
23 |
Correct |
0 ms |
2148 KB |
Output is correct |
24 |
Correct |
0 ms |
2148 KB |
Output is correct |
25 |
Correct |
0 ms |
2148 KB |
Output is correct |
26 |
Correct |
0 ms |
2148 KB |
Output is correct |
27 |
Correct |
0 ms |
2148 KB |
Output is correct |
28 |
Correct |
0 ms |
2148 KB |
Output is correct |
29 |
Correct |
0 ms |
2148 KB |
Output is correct |
30 |
Correct |
0 ms |
2148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
300 ms |
2148 KB |
Output is correct |
2 |
Correct |
112 ms |
2148 KB |
Output is correct |
3 |
Correct |
480 ms |
2148 KB |
Output is correct |
4 |
Correct |
264 ms |
2148 KB |
Output is correct |
5 |
Correct |
128 ms |
2148 KB |
Output is correct |
6 |
Correct |
912 ms |
2148 KB |
Output is correct |
7 |
Correct |
272 ms |
2148 KB |
Output is correct |
8 |
Execution timed out |
1000 ms |
2148 KB |
Program timed out |
9 |
Halted |
0 ms |
0 KB |
- |