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 SUT at 2012-11-24 22:47:20 on Problem 3176
#include <stdio.h>
#define max(x,y) (x>y?x:y)

int main()
{
    int n, i, j, a, dp[355] = {0}, r = 0;
    scanf("%d", &n);
    for(i=1; i<=n; i++)
    {
        for(j=i; j>=1 && scanf("%d", &a); j--)
        {
            dp[j] = max(dp[j], dp[j-1])+a;
            r = max(r, dp[j]);
        }
    }
    printf("%d\n", r);
    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