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

我哪里错了??为什么WA?? 帮忙给看看: 谢谢!!!!

Posted by kikif at 2007-09-08 13:27:53 on Problem 3230
#include <iostream>
#include <fstream>
using namespace std;

int n,m;
int cost[110][110];    //traval expense
int income[110][110]; //在i city第j天的收入

int	total[110][110]; // 指第i城市在第j天的最大总收入



void print(){
	int i,j;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cout<<total[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;

}


int main(){
//	ifstream cin("data.txt");

	while(1){
		cin>>n>>m;
		if(n==0)break;

		int i,j,k;

		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				cin>>cost[i][j];
			//	cout<<cost[i][j]<<" ";
			}
		//	cout<<endl;
		}

		for(i=1;i<=n;i++){
			for(j=1;j<=m;j++){
				cin>>income[i][j];
			//	cout<<income[i][j]<<" ";

			}
		//	cout<<endl;
		}

		memset(total,0,sizeof(total));
		for(i=1;i<=n;i++){
			total[i][1]=income[i][1]-cost[1][i];
		}
	
		for(i=2;i<=m;i++){//第i天
			for(j=1;j<=n;j++){//第j个城市
				for(k=1;k<=n;k++){ //转到k city
					int sum=total[j][i-1]+income[k][i]-cost[j][k];

					if(sum>total[k][i]){
						total[k][i]=sum;
					}


				}
			//	print();
			}
		}
		int max=0;
		for(i=1;i<=n;i++){
			if(total[i][m]>max)max=total[i][m];
		}
		cout<<max<<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