POj 3250
来源:互联网 发布:latex 矩阵虚线 编辑:程序博客网 时间:2024/05/22 01:58
#include<iostream>
#include "stdio.h"
#include<queue>
#include<string>
using namespace std;
class QUEUE
{
public:
int f;
int r;
long a[100000];
void init()
{
f=1;
r=0;
}
void push(int n)
{
a[++r]=n;
}
int pop_front()
{
return a[f++];
}
int pop_rear()
{
return a[r--];
}
int get_front()
{
return a[f];
}
int get_rear()
{
return a[r];
}
int empty()
{
return r<f;
}
};
long a[80001];
long dp[80001];
int higher[100000];
int main()
{
//存储比 i大的第一头牛的下标
int N;
int T;
int W;
int MaxP;
int i,j,k;
QUEUE que;
while(scanf("%d",&T)!=EOF)
{
memset(dp,0,sizeof(dp));
memset(higher,0,sizeof(dp));
que.init();
for(i=1;i<=N;i++)
{
scanf("%d",&a[i]);
}
a[N+1]=2100000000;
for(i=1;i<=N+1;i++)
{
while(!que.empty()&&a[i]>=a[que.get_rear()])
{
int ii=que.pop_rear();
higher[ii]=i;
}
que.push(i);
}
unsigned long sum=0;
for(i=1;i<=N;i++)
if(higher[i]-i-1>0)
sum+=higher[i]-i-1;
printf("%u\n",sum);
}
}
- POJ 3250
- POj 3250
- poj 3250
- 【POJ】3250
- 【单调栈】POJ 3250
- POJ 3250 单调堆栈
- POJ 3250 单调栈
- poj 3250 Floyd求负圈
- POJ 3250 hair cut
- poj 3250 单调栈
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- 使用C#的WebService实现客户端软件在线升级
- java中BigDecimal的应用
- 读《重构》,学习Collections.unmodifiableList()用法
- hdu4342 History repeat itself-------多校联合五
- 设置morenavigationcontroller的tabbaritem
- POj 3250
- 2012 Multi-University Training Contest 5-1001 hdu4340(Virus原创)
- /etc/rc.d/rc文件分析
- 自定义Eclipse背景色(黑色)
- 在新硬件上加载网卡驱动,出现e1000e: disagrees about version of symbol struct_module的解决
- gdb学习笔记
- 算法的力量
- HttpSession创建session
- Hibernate框架 初学