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 ddmbr at 2010-08-20 11:49:34 on Problem 1163
#include<stdio.h>

main(){
int max,n,i,j;
scanf("%d",&n);
int m[102][102],a[102][102];

for(i=1;i<=n;i++){
for(j=1;j<=i;j++)
scanf("%d",&m[i][j]);
}
a[1][1]=m[1][1];
for(i=2;i<=n;i++){
a[i][1]=m[i][1]+a[i-1][1];
for(j=2;j<=i-1;j++){
if(a[i-1][j]<=a[i-1][j-1]){
a[i][j]=m[i][j]+a[i-1][j-1];
}else{
a[i][j]=m[i][j]+a[i-1][j];
}
a[i][i]=a[i-1][i-1]+m[i][i];
}
}
max=a[n][1];
for(i=2;i<=n;i++){
if(a[n][i]>max)
max=a[n][i];
}
printf("%d",max);

}

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