题目链接:http://poj.org/problem?id=3298
找一个最长不要求连续的子序列,如a1 > a3 < a6 > a7 ...
举个例子模拟一下差不多明白了,a[i - 1]与a[i]有依赖关系。
//#pragma comment(linker, "/STACK:102400000, 102400000")
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long LL;
typedef pair <int, int> P;
const int N = 1e5 + ;
int a[N]; int main()
{
int t, n;
scanf("%d", &t);
while(t--) {
scanf("%d", &n);
for(int i = ; i <= n; ++i) {
scanf("%d", a + i);
}
int Max = , num = a[];
for(int i = ; i <= n; ++i) {
if(Max % && a[i] < num) {
Max++;
} else if(Max % == && a[i] > num) {
Max++;
}
num = a[i];
}
printf("%d\n", Max);
}
return ;
}