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

这么弱的数据真的大丈夫?

Posted by sunl449554866 at 2014-08-26 23:58:10 on Problem 1050
#include<iostream>
#include<vector>
#define NINF -2000000
using namespace std;

vector<vector<int> > array(200,vector<int>(200,0));

long Colum_Sum (int colum, int rowT, int rowB)
{
	long sum = 0;
	for (int i = rowT; i <= rowB; ++i) sum += array[i][colum];
	return sum;
}
int main()
{
	int N;
	long ans = NINF;
	vector<long> left(200,0);
	cin >> N;
	for (int i = 1; i <= N; ++i){
		for (int j = 1; j <= N; ++j){
			cin >> array[i][j];
		}
	}
	
	for (int i = 1; i <= N; ++i){
		for (int j = i; j <= N; ++j){
			left[1] = Colum_Sum(1,i,j);
			if (ans < left[1]) ans = left[1];
			for (int k = 2; k <= N; ++k){
				left[k] = Colum_Sum(k,i,j);
				if (left[k-1] > 0) left[k] += left[k-1];
				if (ans < left[k]) ans = left[k];
			}
		}
	}
	
	cout<< ans <<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