Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这叫滚动数组么?水题

Posted by haha___wokao at 2013-11-02 21:51:00 on Problem 1163
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator