アドレス:http : //acm.hdu.edu.cn/showproblem.php?pid=1257
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; const int maxn = 3e4 + 10 ; typedef long long ll; ll a [maxn]; ll dp [maxn]; int main() { ll n; while(cin >> n) { for(int i = 0 ; i <n; i ++ ) cin >> a [i]; for(int i = 0 ; i <n; i ++) dp [i] = 1 ; ll maxx = -1 ; for(int i = 1 ; i <n; i ++ ) { for(int j = 0 ; j <i; j ++ ) { if(a [i]> a [j]) { dp [i] = max(dp [i]、dp [j] + 1); // 引き続き考えて、選択するかしないかを選択する } } maxx = max(dp [i]、maxx); } cout << maxx << endl;} }