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> #include <algorithm> using namespace std; int N; int cows[355][355]; void solve() { for(int line=1;line<N;line++) { cows[line][0]+=cows[line-1][0]; for(int r=1;r<line;r++) cows[line][r]+=max(cows[line-1][r-1],cows[line-1][r]); } printf("%d",*max_element(cows[N-1],cows[N-1]+N)); } int main() { scanf("%d",&N); for(int i=0;i<N;i++) for(int *s=cows[i],*end=s+i+1;s<end;s++) scanf("%d",s); if(N==1)printf("%d",cows[0][0]); else solve(); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator