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

Re:既然水。。。比比谁的短。。。

Posted by asuran at 2009-10-13 12:31:26 on Problem 2533
In Reply To:既然水。。。比比谁的短。。。 Posted by:niuzheng168 at 2009-07-21 11:37:14
#include <iostream>
#include <algorithm>
using namespace std;

int main(int argc, char* argv[])
{
    int N;
    scanf("%d", &N);

    int num[1000];
    for (int i = 0; i < N; ++i)scanf("%d", &num[i]);

    int DP[1000];    
    fill(&DP[0], &DP[N], 1);

    for (int i = 1; i < N; ++i)
        for (int j = 0; j < i; ++j)
            if (num[j] < num[i]) DP[i] = max(DP[j] + 1, DP[i]);

    cout << *max_element(&DP[0], &DP[N])<<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