Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

直接DP?大水题一个。

Posted by KatrineYang at 2016-07-13 13:08:43 on Problem 1157
#include <iostream>
using namespace std;

int mx(int a, int b){
	if(a > b) return a;
	return b;
}

const int MININT = -2147483648;

int main() {

	int res[104][104] = {0};
	int val[104][104] = {0};
	int F, V;
	cin >> F >> V;
	for(int i = 1; i <= F; i++){
		for(int j = 1; j <= V; j++){
			cin >> val[j][i];
		}
	}
	for(int i = 0; i <= V; i++){
		for(int j = 0; j <= F; j++){
			if(i < j) {
				res[i][j] = MININT;
				continue;
			}
			if(i == 0 || j == 0) continue;
			int tmp = res[i-1][j];
			int temp = res[i-1][j-1] + val[i][j];
			res[i][j] = mx(tmp, temp);
		}
	}
	cout << res[V][F] << endl;
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator