BZOJ3401: [Usaco2009 Mar]Look Up 仰望
3401: [Usaco2009 Mar]Look Up 仰望
Time Limit: 3 Sec Memory Limit: 128 MB
Submit: 87 Solved: 58
[Submit][Status]
Description
Input
Output
Sample Input
3
2
6
1
1
2
Sample Output
3
0
6
6
0
HINT
Source
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 100000+5
#define maxm 500+100
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define mod 1000000007
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}
return x*f;
}
int n,top,a[maxn],b[maxn],sta[maxn];
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
n=read();
for1(i,n)a[i]=read();
for1(i,n)
{
while(top&&a[i]>a[sta[top]])b[sta[top--]]=i;
sta[++top]=i;
}
for1(i,n)printf("%d\n",b[i]);
return ;
}
BZOJ3401: [Usaco2009 Mar]Look Up 仰望的更多相关文章
- BZOJ 3401: [Usaco2009 Mar]Look Up 仰望( 单调栈 )
n <= 105 , 其实是10 ^ 5 ....坑...我一开始写了个模拟结果就 RE 了.. 发现这个后写了个单调栈就 A 了... ---------------------------- ...
- 3401: [Usaco2009 Mar]Look Up 仰望
3401: [Usaco2009 Mar]Look Up 仰望 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 136 Solved: 81[Submi ...
- 【BZOJ】3401: [Usaco2009 Mar]Look Up 仰望(单调栈)
http://www.lydsy.com/JudgeOnline/problem.php?id=3401 还能更裸一些吗.. 维护一个递减的单调栈 #include <cstdio> #i ...
- P3401: [Usaco2009 Mar]Look Up 仰望
这道题第一眼还以为是树状数组,于是乎打着打着也是能过的 ; var n,i,j,maxx:longint; h,l:array[..] of longint; p:array[..] of longi ...
- BZOJ 3401: [Usaco2009 Mar]Look Up 仰望(离线+平衡树)
刷银组刷得好开心= = 离线按权值排序,从大到小插入二叉树,查找树中比这个数大的 CODE: #include<cstdio>#include<iostream>#includ ...
- bzoj 3401: [Usaco2009 Mar]Look Up 仰望【单调栈】
用单调递减的栈从后往前扫一遍即可 #include<iostream> #include<cstdio> using namespace std; const int N=10 ...
- bzoj 3399: [Usaco2009 Mar]Sand Castle城堡
3399: [Usaco2009 Mar]Sand Castle城堡 Time Limit: 3 Sec Memory Limit: 128 MB Description 约翰用沙子建了一座城堡.正 ...
- BZOJ3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队
3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 89 Solve ...
- BZOJ3399: [Usaco2009 Mar]Sand Castle城堡
3399: [Usaco2009 Mar]Sand Castle城堡 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 22 Solved: 17[Sub ...
随机推荐
- Android Toast 提示按两次返回键退出
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceS ...
- [Angular 2] Passing Observables into Components with Async Pipe
The components inside of your container components can easily accept Observables. You simply define ...
- [Docker] Docker Machine intro
List all the docker machine: docker-machine ls Can check 'ip' and 'status': docker-machine ip defaul ...
- [AngularJS] Services, Factories, and Providers -- value & Providers
Creating a Value Object Sometimes you have javascript object defined: //value object var droidValue ...
- JBoss 系列九十六:JBoss MSC - 简介及一个简单演示样例
什么是 JBoss MSC JBoss MSC 即 JBoss Modular Service Container,是第三代 JBoss 产品 JBoss 7和WildFfly的内核,JBoss MS ...
- git常用命令<转>
(转自)https://www.akii.org/git-concise-operating-tutorial.html git工作原理: 分布式,每个克隆或更新远程仓库的用户都拥有⼀一份最新的完整的 ...
- 神器-Sublime Text 3 代码编辑器安装与使用
一.软件获取 1.软件下载地址:http://www.sublimetext.com/3. 2.注册机和汉化下载:http://files.cnblogs.com/files/1312mn/subli ...
- Win7启动修复MBR(Win7+Linux删除Linux后进入grub rescue的情况)
事因:我的笔记本原先同时安装了Win7+Linux,昨天发现硬盘实在不够用(才60G,虽然还有个500G的移动硬盘),就想把里面的Ubuntu格了.都是用虚拟机做测试的多.后来就格了Ubuntu所在的 ...
- libthrift0.9.0解析(一)之TServer
TServer 属性serverTransport 为TServerTransport类型,类图如下: 构造函数,简单根据args设置几个成员,大部分是工厂类: protected TServer(A ...
- cocoapods出现Diff: /../Podfile.lock: No such file or directory错误
第一种解决方法: 关闭Xcode,重新执行pod install,之后再重新打开Xcode运行. 第二种解决方法: 删除以下文件: xcworkspacePodfile.lockPods文件夹~/Li ...