bzoj1660
来源:互联网 发布:优化国税环境建设 编辑:程序博客网 时间:2024/05/18 16:54
分析:单调栈。。直接计算最后的贡献就会好算很多,不要单独算c,不然想半天想不出来。。
#include<iostream> #include<cstdio> using namespace std; int n,top,a[80001],s[80001]; long long ans; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=1;i<=n;i++) { if(a[i]<s[top]) ans+=top; else { while(a[i]>=s[top]&&top) top--; ans+=top; } s[++top]=a[i]; } printf("%lld",ans); return 0; }
0 0
- bzoj1660
- bzoj1660栈
- bzoj1660[Usaco2006 Nov]Bad Hair Day 乱发节
- 【bzoj1660】【单调栈】Bad Hair Day 乱发节
- [BZOJ1660] [Usaco2006 Nov]Bad Hair Day 乱发节
- 【BZOJ1660】【Usaco2006 Nov】Bad Hair Day 乱发节
- 单调栈——BZOJ1660/Luogu2866 [USACO06NOV]Bad Hair Day
- [BZOJ1660][Usaco2006 Nov]Bad Hair Day 乱发节(单调栈)
- 同一环境下新建Standby RAC库
- 数据库分区分表以及读写分离
- Android 中 加载Bitmap时,造成的Out of memory 问题
- Codeforces Round #402 (Div. 1) A. String Game
- Oracle索引2--index_stats视图
- bzoj1660
- [BZOJ2120]数颜色(带修改莫队)
- 安卓中的乱码以及编码问题
- EasyDarwin开源流媒体项目
- 将h264的es流使用mpeg4打包时的一些点滴
- 2017年3月5号
- PHP Apache环境的搭建,安装httpd.exe闪退处理方式
- git本地push代码报broken pipe
- 不允许在此位置使用注释 @Field_Method_Parameter_Annotation