51nod 1297
来源:互联网 发布:电话录音软件 编辑:程序博客网 时间:2024/06/16 05:08
思路:
搞个栈模拟一下,也才5w;
直接wa1了。。然后想到井口如果都进不去那就。。。一定GG了。
搞个栈模拟一下,也才5w;
直接wa1了。。然后想到井口如果都进不去那就。。。一定GG了。
所以维护一下从井口到井底是非递增的就好了;
#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>#include <stack>#include <queue>using namespace std;stack<int>q;int n,m;int main(){ int u,x; int tmp=1e9+1; scanf("%d%d",&n,&m); while(n--) { scanf("%d",&x); if(tmp>=x) { q.push(x); tmp=x; } else { x=tmp; q.push(x); } } int ans=0; while(m) { scanf("%d",&x); m--; while(!q.empty()&&q.top()<x) q.pop(); if(!q.empty()) { q.pop(); ans++; } } printf("%d\n",ans); return 0;}
0 0
- 51nod 1297
- 51Nod
- 51Nod
- 51nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- 51Nod
- Android数据存储技术 (一) : File存储
- 记2016.10.15百度面试经历,软件研发工程师
- sklearn初步学习
- [leetcode]14. Longest Common Prefix
- “读心”不再是幻想
- 51nod 1297
- 人造食品会改变世界吗?
- Apizza用法简介-Http请求模拟工具
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
- 构建属于自己的 Linux 发行版
- 90后科技新贵:挣钱没有创造好玩的东西重要
- show database 没有mysql数据库 解决办法
- 90后一代,“苹果”的传人
- 去哪儿网2017校招软件开发类编程题