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 <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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator