poj 3250 Bad Hair Day 单调栈
来源:互联网 发布:linux配置java环境 编辑:程序博客网 时间:2024/06/06 06:56
题意:n头牛往右看能看到的头顶总数(即身高小于它的)
#include <map>#include <set>#include <queue>#include <stack>#include <vector>#include <string>#include <math.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <iostream>#include <algorithm>using namespace std;#define lson l, mid, rt << 1#define rson mid + 1, r, rt << 1 | 1#define ls rt << 1#define rs rt << 1 | 1#define pi acos(-1.0)#define eps 1e-8#define asd puts("sdfsdfsdfsdfsdfsdf");typedef long long ll;typedef __int64 LL;const int inf = 0x3f3f3f3f;stack<int> s;ll sum;int main(){ int n, h, t; while( ~scanf("%d", &n) ) { sum = 0; scanf("%d", &h); while( !s.empty() ) s.pop(); s.push( h ); for(int i = 1; i < n; ++i) { scanf("%d", &t); while( !s.empty() && t >= s.top() ) s.pop(); sum += s.size(); s.push(t); } printf("%lld\n", sum); } return 0;}
0 0
- poj 3250:Bad Hair Day---单调栈
- POJ 3250 Bad Hair Day(单调栈)
- POJ 3250 Bad Hair Day(单调栈)
- POJ 3250 Bad Hair Day 单调栈
- poj 3250 Bad Hair Day 单调栈
- [单调栈] poj 3250 Bad Hair Day
- POJ 3250 Bad Hair Day 【单调栈】
- poj 3250 Bad Hair Day 【单调栈】
- poj 3250 Bad Hair Day(单调栈)
- Poj 3250 Bad Hair Day 【单调栈】
- POJ 3250 - Bad hair day(单调栈)
- poj-3250 Bad Hair Day(单调栈)
- Bad Hair Day(POJ 3250) 单调栈
- poj 3250 Bad Hair Day单调栈
- Bad Hair Day -- 3250poj 单调栈
- POJ 3250 Bad Hair Day (单调栈)
- poj 3250 Bad Hair Day(单调栈)
- POJ 3250 Bad Hair Day【单调栈】
- C#Socket服务器开发(Unity)
- 阿里云 IIS 500错误
- Java 学习————线程直接通信
- Pig 知识盲点
- 深入理解tomcat读书笔记
- poj 3250 Bad Hair Day 单调栈
- GLIB 常用数据结构介绍 2
- Putting it Together: Understanding Pointers
- 物流运交管理系统 派车作业
- MFC 字符串类CString 源代码
- servlet项目出现405错误
- python中使用mahotas包函数实现图像阈值处理
- 公倍数
- iOS开发:获取一个视频、音频文件的播放时长