#include<cstdio>
#include<algorithm>
#include<stack>
#include<cctype>
using namespace std;
struct cow{
int id;
int data;
cow(int id=,int data=):id(id),data(data){
}
}ans[];
stack<cow> q;
int n,tmp,cnt;
inline bool cmp(const cow &a,const cow &b)
{
return a.id<b.id;
}
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d",&tmp);
while(!q.empty()&&q.top().data<tmp)
{
ans[++cnt]=q.top();
ans[cnt].data=i;
q.pop();
}
q.push(cow(i,tmp));
}
while(!q.empty())
{
ans[++cnt]=q.top();
ans[cnt].data=;
q.pop();
}
sort(ans+,ans++n,cmp);
for(int i=;i<=n;i++) printf("%d\n",ans[i].data);
return ;
}

洛谷P2947 [USACO09MAR]向右看齐Look Up的更多相关文章

  1. 洛谷 P2947 [USACO09MAR]向右看齐Look Up【单调栈】

    题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again stan ...

  2. 洛谷 P2947 [USACO09MAR]向右看齐Look Up

    目录 题目 思路 \(Code\) 题目 戳 思路 单调栈裸题 \(Code\) #include<stack> #include<cstdio> #include<st ...

  3. 洛谷P2947 [USACO09MAR]仰望Look Up

    P2947 [USACO09MAR]仰望Look Up 74通过 122提交 题目提供者洛谷OnlineJudge 标签USACO2009云端 难度普及/提高- 时空限制1s / 128MB 提交   ...

  4. 【洛谷P2947】向右看齐

    向右看齐 题目链接 此题可用单调栈O(n)求解 维护一个单调递减栈,元素从左到右入栈 若新加元素大于栈中元素,则栈中元素的仰望对象即为新加元素 每次将小于新加元素的栈中元素弹出,记录下答案 #incl ...

  5. 洛谷 P2947 [USACO09MAR]仰望Look Up

    题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again stan ...

  6. P2947 [USACO09MAR]向右看齐Look Up--单调栈

    单调栈真的很好用呢! P2947 [USACO09MAR]向右看齐Look Up 题目描述 Farmer John's N (1 <= N <= 100,000) cows, conven ...

  7. 【luogu P2947 [USACO09MAR]向右看齐Look Up】 题解

    题目链接:https://www.luogu.org/problemnew/show/P2947 因为在单调队列上被dalao们锤爆 怒刷单调队列题 何为单调队列? 设我们的队列为从左至右单调递增 对 ...

  8. luogu P2947 [USACO09MAR]向右看齐Look Up |单调队列

    题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again stan ...

  9. 洛谷 P2945 [USACO09MAR]沙堡Sand Castle 题解

    题目传送门 大概思路就是把这两个数组排序.在扫描一次,判断大小,累加ans. #include<bits/stdc++.h> using namespace std; int x,y,z; ...

随机推荐

  1. case expressions must be constant expressions

    As the error message states, the case expressions must be constant. The compiler builds this as a ve ...

  2. JS---案例:tab切换效果

    案例:tab切换效果 获取所有的li标签 第一件事:把这个a所在的所以兄弟元素的类样式全部移除 (removeAttributes) 第二件事:当前点击的a父级元素li (点击这个a所在的所在元素li ...

  3. python使用cPickle模块序列化实例

    python使用cPickle模块序列化实例 这篇文章主要介绍了python使用cPickle模块序列化的方法,是一个非常实用的技巧,本文实例讲述了python使用cPickle模块序列化的方法,分享 ...

  4. grpc入门2

    rpc-gateway使用(同时提供rpc和http接口) 介绍第三方库 https://github.com/grpc-ecosystem/grpc-gateway 在grpc之上加一层代理并转发, ...

  5. CesiumLab V1.4 新功能 BIM数据处理

    我也没想到,BIM数据处理一下拖了这么久才有个交代.我们照例先放图   Revit官方的示例数据   隐藏屋顶+俯视   曾经因为太大而无法导出无法处理的医院模型   室内装修方案模型 最近和很多做b ...

  6. [DEPRECATION] Encountered positional parameter near xxx Positional parameter are considered deprecated; use named parameters or JPA-style positional parameters instead.

    WARN:30 20:55:45,340ms- [HqlSqlWalker]1009行-[DEPRECATION] Encountered positional parameter near line ...

  7. 如何在TypeScript中使用JS类库

    使用流程 1.首先要清除类库是什么类型,不同的类库有不同的使用方式 2.寻找声明文件 JS类库一般有三类:全局类库.模块类库.UMD库.例如,jQuery是一种UMD库,既可以通过全局方式来引用,也可 ...

  8. SpringBooot-基础<2>-POM.xml配置

    SpringBooot-基础<2>-POM.xml配置 项目创建完成后,需要配置pom.xml文件. pom.xml里面的配置,按需进行添加,这里提供一份参考,后面做笔记会都用到. < ...

  9. Breakpoint 断点只生效一次

  10. <a>标签操作

    1.点击后onclick事件失效,变灰,不可用 onclick(this); //事件传递this对象 function viewMm(obj) { $(obj).removeAttr("o ...