博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 3298 Antimonotonicity (思维)
阅读量:4562 次
发布时间:2019-06-08

本文共 897 字,大约阅读时间需要 2 分钟。

题目链接:

找一个最长不要求连续的子序列,如a1 > a3 < a6 > a7 ...

举个例子模拟一下差不多明白了,a[i - 1]与a[i]有依赖关系。

1 //#pragma comment(linker, "/STACK:102400000, 102400000") 2 #include 
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 using namespace std;14 typedef long long LL;15 typedef pair
P;16 const int N = 1e5 + 5;17 int a[N];18 19 int main()20 {21 int t, n;22 scanf("%d", &t);23 while(t--) {24 scanf("%d", &n);25 for(int i = 1; i <= n; ++i) {26 scanf("%d", a + i);27 }28 int Max = 1, num = a[1];29 for(int i = 2; i <= n; ++i) {30 if(Max % 2 && a[i] < num) {31 Max++;32 } else if(Max % 2 == 0 && a[i] > num) {33 Max++;34 }35 num = a[i];36 }37 printf("%d\n", Max);38 }39 return 0;40 }

 

转载于:https://www.cnblogs.com/Recoder/p/5821610.html

你可能感兴趣的文章
Leetcode 367. Valid Perfect Square
查看>>
UVALive 3635 Pie(二分法)
查看>>
win系统查看自己电脑IP
查看>>
Backup&recovery备份和还原 mysql
查看>>
全局变量、局部变量、静态全局变量、静态局部变量的区别
查看>>
一道面试题及扩展
查看>>
Unity 3D 我来了
查看>>
setup elk with docker-compose
查看>>
C++ GUI Qt4学习笔记03
查看>>
Java基础回顾 —反射机制
查看>>
【问底】徐汉彬:亿级Web系统搭建——单机到分布式集群(三)
查看>>
c# 前台js 调用后台代码
查看>>
2017-02-20 可编辑div中如何在光标位置添加内容
查看>>
$.ajax()方法详解
查看>>
day42
查看>>
jquery操作select(增加,删除,清空)
查看>>
Sublimetext3安装Emmet插件步骤
查看>>
MySQL配置参数
查看>>
全面理解Java内存模型
查看>>
A - Mike and palindrome
查看>>