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<iostream> #include<algorithm> #include<cstring> using namespace std; int matrix[105][105]; int N; int main() { cin>>N; memset(matrix,0,sizeof(matrix)); for(int i=0;i<N;i++) for(int j=0;j<i+1;j++) { cin>>matrix[i][j]; if(j==0&&i>0) matrix[i][j]+=matrix[i-1][j]; if(j>0&&i>0) matrix[i][j]+=max(matrix[i-1][j],matrix[i-1][j-1]); } int maxn=0; for(int i=0;i<N;i++) if(matrix[N-1][i]>maxn) maxn=matrix[N-1][i]; cout<<maxn<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator