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 ouyangwenbin at 2014-04-02 13:45:54 on Problem 1163
#include <cstdio>
#include <cstdlib>
#include <cstring>

int f[2][110];

int _max ( int x, int y )
{
    if ( x > y ) return x;
    return y;
}

int main ()
{
    int n;
    scanf ( "%d", &n );
    int i, j, zb = 0;
    scanf ( "%d", &f[0][1] );f[0][0] = f[0][1];
    for ( i = 2; i <= n; i ++ )
    {
     for ( j = 1; j <= i; j ++ )
      scanf ( "%d", &f[(zb^1)][j] );
     for ( j = 1; j <= i; j ++ )
      f[(zb^1)][j] += _max ( f[zb][j-1], f[zb][j] );
     f[(zb^1)][0] = f[(zb^1)][1];
     zb=(zb^1);
    }
    int ans = -999999999;
    for ( i = 1; i <= n; i ++ )
     ans = _max(ans,f[zb][i] );

    printf ( "%d\n", ans );
    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