spoj 95
来源:互联网 发布:快递数据 编辑:程序博客网 时间:2024/05/02 05:02
栈应用 ...... 水题
#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>#include<queue>using namespace std;int a[1010], b[1010];int main(){ int n; while(scanf("%d",&n) == 1 && n) { for(int i = 0; i < n; i++) scanf("%d",&a[i]); int top = 0, ff = 0, bb = 1; while(true) { while(top && b[top-1] == bb) top--, bb++; if(a[ff] == bb) ff++, bb++; else b[top++] = a[ff++]; if(ff == n+1) break; } if(bb == n+1) puts("yes"); else puts("no"); } return 0;}
- spoj 95
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- Flex使用远程的XML数据
- 超级硬盘数据恢复软件 4.2.0.0注册码破解版
- hdu 1494 跑跑卡丁车(dp)
- HTTPS是如何保证连接安全:每位Web开发者都应知道的
- Reddit的科学:为什么有些想法能统治网络
- spoj 95
- HDU 2333 & POJ 3497 & UVA 12124 Assemble (二分答案)
- 鹊桥的长度
- 引用作为函数返回值的情况
- PE
- HDOJ 1297
- 概率DP问题整理(一)
- 百度地图不能从定位的BDLocation里获取地址怎么办?
- centos网卡配置