题目:Longest Ordered Subsequence (POJ 2533)
链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=2533
#include <iostream>
#include <vector>
using namespace std;
int LIS(const vector<int> &data)
{
vector<int> num(data.size());
int max = 0;
for (size_t i = 0; i < data.size(); ++i)
{
num[i] = 1;
for (size_t j = 0; j < i; ++j)
{
if (data[i] > data[j] && num[j] + 1 > num[i])
{
num[i] = num[j] + 1;
}
}
if (num[i] > max) max = num[i];
}
return max;
}
int main(int argc, char **argv)
{
int n;
vector<int> data;
cin >> n;
while (n--)
{
int tmp;
cin >> tmp;
data.push_back(tmp);
}
cout << LIS(data) << endl;
return 0;
}