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 |
With the transition equation of others, I still get WA. It really sucks...In Reply To:为什么老是wa呢 Posted by:leilei at 2005-10-03 22:14:39 #include <iostream> using namespace std; class Person { public: int b, w; }; Person p[1000]; int n, dp[1000][16][16]; int max( int a, int b ) { return a < b ? b : a; } int main() { int s, t, i = 0; // freopen( "2626.txt", "r", stdin ); while( scanf( "%d%d", &p[i].w, &p[i].b ) != -1 ) i++; n = i; memset( dp, 0, sizeof( dp ) ); dp[0][1][0] = p[0].w; dp[0][0][1] = p[0].b; for( i = 1; i < n; i++ ) for( s = 1; s <= 15; s++ ) for( t = 1; t <= 15; t++ ) { if( s + t <= i + 1 ) dp[i][s][t] = max( dp[i - 1][s][t], max( dp[i - 1][s - 1][t] + p[i].w, dp[i - 1][s][t - 1] + p[i].b ) ); } printf( "%d\n", dp[n - 1][15][15] ); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator