Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
乱做#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator