【最大上升子序列+经典题】北大 poj 2533 Longest Ordered Subsequence
2012-07-08 11:39
417 查看
/* THE PROGRAM IS MADE BY PYY */ /*----------------------------------------------------------------------------// Copyright (c) 2012 panyanyany All rights reserved. URL : http://poj.org/problem?id=2533 Name : 2533 Longest Ordered Subsequence Date : Sunday, July 8, 2012 Time Stage : half an hour Result: 10398877 panyanyany 2533 Accepted 172K 16MS C++ 1400B 2012-07-08 11:40:02 Test Data : Review : //----------------------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <vector> #include <algorithm> #include <iostream> #include <queue> #include <set> #include <string> using namespace std ; #define MEM(a, v) memset (a, v, sizeof (a)) // a for address, v for value #define max(x, y) ((x) > (y) ? (x) : (y)) #define min(x, y) ((x) < (y) ? (x) : (y)) #define INF (0x3f3f3f3f) #define MAXN 1009 #define L(x) ((x)<<1) #define R(x) (((x)<<1)|1) #define M(x, y) (((x)+(y)) >> 1) #define DB // int dpInc[MAXN], a[MAXN]; int LIS(int a[], int n) { int i, j; for (i = 0; i < n; ++i) { dpInc[i] = 1; for (j = 0; j < i; ++j) { if (a[j] < a[i]) dpInc[i] = max(dpInc[i], dpInc[j] + 1); } } j = 0; for (i = 0; i < n; ++i) j = max(j, dpInc[i]); return j; } int main() { int i, n; while (scanf("%d", &n) != EOF) { for (i = 0; i < n; ++i) scanf("%d", a+i); printf("%d\n", LIS(a, n)); } return 0; }
相关文章推荐
- POJ 2533 Longest Ordered Subsequence(最大上升子序列)
- poj2533-Longest Ordered Subsequence(最长上升子序列)
- POJ - 2533 Longest Ordered Subsequence —— 最长不连续上升子序列
- POJ 2533 Longest Ordered Subsequence(DP最长上升子序列O(n^2)&&O(nlogn))
- 每日三题-Day5-A(POJ 2533 Longest Ordered Subsequence 最长上升子序列O(nlogn)解法)
- POJ-2533 Longest Ordered Subsequence (线性dp 最长上升子序列)
- poj_2533 Longest Ordered Subsequence(最长上升子序列)
- poj 2533 Longest Ordered Subsequence (最长上升子序列)
- Longest Ordered Subsequence - POJ 2533 最长上升子序列
- poj2533--Longest Ordered Subsequence(dp:最长上升子序列)
- POJ 2533 Longest Ordered Subsequence(最长上升子序列)
- POJ2533 -Longest Ordered Subsequence最长上升子序列-动规和nlogn二分算法详解
- POJ 2533 Longest Ordered Subsequence(LIS:最长上升子序列)
- poj 2533 Longest Ordered Subsequence(最长上升子序列)
- POJ 2533 Longest Ordered Subsequence 最长上升子序列
- poj 2533 Longest Ordered Subsequence(最长上升子序列)
- Longest Ordered Subsequence POJ - 2533(最长上升子序列)
- POJ 2533 Longest Ordered Subsequence(最长上升子序列模版)
- 求最大上升序列的二分搜索算法 poj 2533 Longest Ordered Subsequence
- Longest Increasing Subsequence[LIS 最长上升子序列问题] (Longest Ordered Subsequence) POJ - 2533 队列优化