HDU 5500 Reorder the Books
来源:互联网 发布:2016淘宝客怎么做推广 编辑:程序博客网 时间:2024/06/11 19:09
http://acm.hdu.edu.cn/showproblem.php?pid=5500
思路
从最大的数向上找,如果发现一个连续比他小的数的位置在他上面,说明发现了一个不用扔的书,ans–
代码
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<cmath>using namespace std;int t,n,ans,maxn,pos;int num[1000010];int main(){ scanf("%d",&t); for(int i=1;i<=t;i++) { maxn=-1e9+7; scanf("%d",&n); ans=n-1; for(int i=1;i<=n;i++) { scanf("%d",&num[i]); if(num[i]>maxn) { maxn=num[i]; pos=i; } } for(int i=pos-1;i>=1;i--) { if(num[i]==ans)//比较巧 ans--; } printf("%d\n",ans);//退格键救不了回车 } return 0;}
阅读全文
1 0
- HDU 5500 Reorder the Books
- HDU 5500 Reorder the Books
- hdu 5500 Reorder the books
- hdu 5500 Reorder the Books
- HDU 5500 Reorder the Books
- hdu 5500 Reorder the Books
- HDU 5500 Reorder the Books
- Reorder the Books HDU - 5500
- HDU 5500 Reorder the Books
- HDU 5500 Reorder the Books
- HDU Reorder the Books
- hdu 5500 Reorder the Books(模拟)
- HDU 5500 Reorder the Books(模拟)
- Reorder the Books-HDU-5500-BC59div2
- hdu acm 5500 Reorder the Books
- hdu 5500 Reorder the Books(贪心)
- HDU 5500:Reorder the Books【规律】
- HDU 5500 Reorder the Books【水题】
- 通过docker实现mysql主从复制
- logstash kafka output 输出原始数据格式
- Thymeleaf
- 中国大学 mooc
- 关于tp5.0 分页的一些样式的问题
- HDU 5500 Reorder the Books
- 虚拟现实的UI制作和交互
- 怎样理解阻塞非阻塞与同步异步的区别?
- 创建MAVEN WEB动态Demo
- 利用for循环打印出不同的三角形
- 配置window版虚拟主机及安装TPshop开源商城
- 文件操作与模板 编程题#3: 整数的输出格式(Coursera 程序设计与算法 专项课程3 C++程序设计 郭炜、刘家瑛;OpenJudge)
- hdu 1517 博弈
- 第二十九天 数据库(中)表操作