Submission #9373

# Submission time Handle Problem Language Result Execution time Memory
9373 2014-09-28T06:00:12 Z maniac On grid (kriii2_O) C++
4 / 4
88 ms 111416 KB
#include<cstdio>
#include<cassert>
#include<cstring>
#include<map>
#include<set>
#include<time.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<limits>
   
using namespace std;

long long gcd( long long b, long long s ){
	return (s!=0) ? gcd( s, b%s ) : b;
}
#define LL long long
#define INF -1000000007
int r,c,a[303][303],s[303][303],d[303][303][303],D[303][303],re;

void solve(){
	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++){
			s[i][j] = s[i][j-1] + a[i][j];
			
		}
	}

	for(int i= 0; i<= r; i++){
		for(int j =0  ; j <=c; j++){
			D[i][j] = INF;
			for(int k = 0 ; k<= c; k++)
				d[i][j][k] = INF;
		}
	}
	re = INF;

	
	d[0][0][1] = 0;
	D[0][0] = 0;
	for(int i = 1 ; i<=r; i++){
		for(int j =1 ; j <=c; j++){
			for(int k = 1; j-k >= 0; k++){
				d[i][j][k] = max(D[i-1][j-k],d[i-1][j][k]) + s[i][j]-s[i][j-k];
				D[i][j] = max(D[i][j],d[i][j][k]);
			}
		}
	}
	for(int i = 1; i <=c ; i++)
		re = max(re,d[r][c][i]);

	printf("%d\n",re);
}

int main(){
	
	solve();


}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 111416 KB Output is correct
2 Correct 0 ms 111416 KB Output is correct
3 Correct 0 ms 111416 KB Output is correct
4 Correct 0 ms 111416 KB Output is correct
5 Correct 0 ms 111416 KB Output is correct
6 Correct 0 ms 111416 KB Output is correct
7 Correct 0 ms 111416 KB Output is correct
8 Correct 0 ms 111416 KB Output is correct
9 Correct 0 ms 111416 KB Output is correct
10 Correct 0 ms 111416 KB Output is correct
11 Correct 0 ms 111416 KB Output is correct
12 Correct 0 ms 111416 KB Output is correct
13 Correct 0 ms 111416 KB Output is correct
14 Correct 0 ms 111416 KB Output is correct
15 Correct 0 ms 111416 KB Output is correct
16 Correct 0 ms 111416 KB Output is correct
17 Correct 0 ms 111416 KB Output is correct
18 Correct 0 ms 111416 KB Output is correct
19 Correct 0 ms 111416 KB Output is correct
20 Correct 0 ms 111416 KB Output is correct
21 Correct 0 ms 111416 KB Output is correct
22 Correct 0 ms 111416 KB Output is correct
23 Correct 0 ms 111416 KB Output is correct
24 Correct 0 ms 111416 KB Output is correct
25 Correct 0 ms 111416 KB Output is correct
26 Correct 0 ms 111416 KB Output is correct
27 Correct 0 ms 111416 KB Output is correct
28 Correct 0 ms 111416 KB Output is correct
29 Correct 0 ms 111416 KB Output is correct
30 Correct 0 ms 111416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 111416 KB Output is correct
2 Correct 12 ms 111416 KB Output is correct
3 Correct 20 ms 111416 KB Output is correct
4 Correct 16 ms 111416 KB Output is correct
5 Correct 12 ms 111416 KB Output is correct
6 Correct 40 ms 111416 KB Output is correct
7 Correct 16 ms 111416 KB Output is correct
8 Correct 56 ms 111416 KB Output is correct
9 Correct 76 ms 111416 KB Output is correct
10 Correct 68 ms 111416 KB Output is correct
11 Correct 28 ms 111416 KB Output is correct
12 Correct 20 ms 111416 KB Output is correct
13 Correct 12 ms 111416 KB Output is correct
14 Correct 68 ms 111416 KB Output is correct
15 Correct 28 ms 111416 KB Output is correct
16 Correct 12 ms 111416 KB Output is correct
17 Correct 48 ms 111416 KB Output is correct
18 Correct 32 ms 111416 KB Output is correct
19 Correct 20 ms 111416 KB Output is correct
20 Correct 20 ms 111416 KB Output is correct
21 Correct 16 ms 111416 KB Output is correct
22 Correct 4 ms 111416 KB Output is correct
23 Correct 16 ms 111416 KB Output is correct
24 Correct 56 ms 111416 KB Output is correct
25 Correct 16 ms 111416 KB Output is correct
26 Correct 4 ms 111416 KB Output is correct
27 Correct 76 ms 111416 KB Output is correct
28 Correct 40 ms 111416 KB Output is correct
29 Correct 28 ms 111416 KB Output is correct
30 Correct 32 ms 111416 KB Output is correct
31 Correct 44 ms 111416 KB Output is correct
32 Correct 72 ms 111416 KB Output is correct
33 Correct 44 ms 111416 KB Output is correct
34 Correct 20 ms 111416 KB Output is correct
35 Correct 8 ms 111416 KB Output is correct
36 Correct 88 ms 111416 KB Output is correct
37 Correct 20 ms 111416 KB Output is correct
38 Correct 28 ms 111416 KB Output is correct
39 Correct 12 ms 111416 KB Output is correct
40 Correct 4 ms 111416 KB Output is correct