POJ 3298 Antimonotonicity (思维)
2016-08-30 13:15
489 查看
题目链接:http://poj.org/problem?id=3298
找一个最长不要求连续的子序列,如a1 > a3 < a6 > a7 ...
举个例子模拟一下差不多明白了,a[i - 1]与a[i]有依赖关系。
找一个最长不要求连续的子序列,如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 + 5; int a ; int main() { int t, n; scanf("%d", &t); while(t--) { scanf("%d", &n); for(int i = 1; i <= n; ++i) { scanf("%d", a + i); } int Max = 1, num = a[1]; for(int i = 2; i <= n; ++i) { if(Max % 2 && a[i] < num) { Max++; } else if(Max % 2 == 0 && a[i] > num) { Max++; } num = a[i]; } printf("%d\n", Max); } return 0; }
相关文章推荐
- poj 3298 Antimonotonicity
- poj 3298 Antimonotonicity 贪心
- POJ 3298 Antimonotonicity 差分约束
- sicily 1448. Antimonotonicity
- Antimonotonicity
- Antimonotonicity
- Sicily 1448. Antimonotonicity
- Sicily 1448. Antimonotonicity
- ZCMU-1231-Antimonotonicity
- 1448. Antimonotonicity
- Antimonotonicity (Standard IO)
- TJU Antimonotonicity
- soj:2876: Antimonotonicity_贪心
- JZOJ.1728. Antimonotonicity
- [ZPG TEST 108] Antimonotonicity【贪心】
- Antimonotonicity
- POJ-1730 Perfect Pth Powers(思维:大数分解素因子)
- POJ 2034 Anti-prime Sequences(素数预处理+DFS回溯)
- [BZOJ2090/2089] [Poi2010]Monotonicity 2/Monotonicity 树状数组优化dp
- poj 2034 Anti-prime Sequences