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

一次AC,秒过,水题...贴出丑陋代码,勿笑...

Posted by Lubin1985 at 2011-03-18 23:38:16 on Problem 1163
一次AC,秒过,水题...贴出丑陋代码,勿笑...
#include <iostream>
using namespace std;
int main()
{
	int inn=0,max=0;
	int n[100][100]={0};
	int tmp[100]={0};

	cin>>inn;
	for(int i=0;i<inn;i++)
		for(int j=0;j<=i;j++)
			cin>>n[i][j];

	for(int i=1;i<inn;i++)
		for(int j=0;j<=i;j++)
	{
		int k;
		for(k=j;k>=j-1 && k>=0;k--)
			if(k<i)
				tmp[k]=n[i][j]+n[i-1][k];
			k++;
		if(j>0 && j<i)
			n[i][j]=tmp[k]>tmp[k+1]?tmp[k]:tmp[k+1];
		else if(j==0 || j==i)
			n[i][j]=tmp[k];						
	}

		for(int i=0;i<inn;i++)
			max=max>n[inn-1][i]?max:n[inn-1][i];
		cout<<max;

	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