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

DP第一次AC

Posted by shoutz at 2013-04-10 14:37:20 on Problem 1157
庆祝一下~
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int f,v;
    int a[110][110];
    int b[110][110];
    for(int i=0;i<100;i++)
        for(int j=0;j<100;j++)
        b[i][j]=-100000;

    while(cin>>f>>v)
    {

        for(int i=0;i<f;i++)
            for(int j=0;j<v;j++)
            cin>>a[i][j];
        b[0][0]=a[0][0];
        for(int i=1;i<v;i++)
        {
            b[0][i]=max(b[0][i-1],a[0][i]);
        }
        for(int i=1;i<f;i++)
            for(int j=i;j<v;j++)
        {
            b[i][j]=max(b[i-1][j-1]+a[i][j],b[i][j-1]);
        }
        cout<<b[f-1][v-1]<<'\n';

    }
}

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