| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
这么弱的数据真的大丈夫?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator