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 1056472097 at 2019-12-27 18:48:54 on Problem 3176
#include <stdio.h>
#include <algorithm>
using namespace std;

int N;
int cows[355][355];
void solve()
{
	for(int line=1;line<N;line++)
	{
		cows[line][0]+=cows[line-1][0];
		for(int r=1;r<line;r++)
			cows[line][r]+=max(cows[line-1][r-1],cows[line-1][r]);
	}
	printf("%d",*max_element(cows[N-1],cows[N-1]+N));
}

int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)
		for(int *s=cows[i],*end=s+i+1;s<end;s++)
			scanf("%d",s);
	if(N==1)printf("%d",cows[0][0]);
	else solve();
	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