JZOJ 1264. 乱头发节
1264. 乱头发节(badhair.pas/c/cpp)
(File IO): input:badhair.in output:badhair.out
Description
每一头牛 i有一个高度 h[i] (1 <= h[i] <= 1,000,000,000)而且面向东方排成一排(在我们的图中是向右)。因此,第i头牛可以看到她前面的那些牛的头,(即i+1, i+2,等等),只要那些牛的高度严格小于她的高度。
例如这个例子:
=
= =
= =
= - = 牛面向右侧 -->
= = =
= - = = =
= = = = = =
1 2 3 4 5 6
aaarticlea/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCACvAREDAREAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09f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o1/8UNG8GeLbrxp4L+F/hXwF4P8D+MPiHYP4RsfD+q/E7RvD/gW20lPGehaLoDzaTq2s6HNpraBbeE9J0tptKyenz8/Prfb8U22NNpWT0+fn59b7fim2z7rpCCgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoA/9k=" alt="" />
牛#1 可以看到她们的发型 #2, 3, 4
牛#2 不能看到任何牛的发型
牛#3 可以看到她的发型 #4
牛#4 不能看到任何牛的发型
牛#5 可以看到她的发型 6
牛#6 不能看到任何牛的发型!
让 c[i] 表示第i头牛可以看到发型的牛的数量;请输出 c[1] 至 c[N]的和。如上面的这个例子,正确解是3 + 0 + 1 + 0 + 1 + 0 = 5。
Input
Lines 2..N+1: 第 i+1 是一个整数,表示第i头牛的高度。
Output
Sample Input
6
10
3
7
4
12
2
Sample Output
5
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#define N 80007
#define LL long long
using namespace std;
LL h[N], n, ans;
struct arr
{
int x, hi;
}f[N]; LL read()
{
LL s = ;
char ch = getchar();
while (ch < '' || ch > '') ch = getchar();
while (ch >= '' && ch <= '') s = s * + ch - '', ch = getchar();
return s;
} int main()
{
freopen("badhair.in", "r", stdin);
freopen("badhair.out", "w", stdout);
n = read();
for (int i = ; i <= n; i++)
h[i] = read();
int head = , tail = ;
f[++tail].hi = h[n];
for (int i = n - ; i >= ; i--)
{
int l = , ac = ;
for (int j = tail; j >= head; j--)
if (h[i] > f[j].hi)
{
ac += f[j].x + ;
l++;
}
else break;
tail = tail - l + ;
f[tail].hi = h[i];
f[tail].x = ac;
ans += ac;
}
cout << ans;
fclose(stdin);
fclose(stdout);
}
JZOJ 1264. 乱头发节的更多相关文章
- bzoj1660:[Usaco2006 Nov]badhair乱头发节
Description 农民John的某 N 头奶牛 (1 <= N <= 80,000) 正在过乱头发节!由于每头牛都 意识到自己凌乱不堪的发型, FJ 希望统计出能够看到其他牛的头发的 ...
- OJP1147括号匹配加强版(栈)与P1153乱头发节(单调栈)
惨兮兮的被刷掉2%的通过率后在经过思考和dalao的指点后终于A掉了这道题 强烈建议修改这题的样例,实在太迷惑人,各种错误算法都能过 比如说这是一份错误代码,看懂了也不要学思路,和正解不知道差到哪里去 ...
- P2866 [USACO06NOV]糟糕的一天Bad Hair Day--单调栈
P2866 [USACO06NOV]糟糕的一天Bad Hair Day 题意翻译 农夫约翰有N (N \leq 80000)N(N≤80000)头奶牛正在过乱头发节.每一头牛都站在同一排面朝东方,而且 ...
- 洛谷P2866 [USACO06NOV]糟糕的一天Bad Hair Day(单调栈)
题目描述 Some of Farmer John's N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self ...
- 福州三中集训day3
Day3数据结构,强无敌. 基本讲的是栈,队列,链表,都是些还会的操作,然后接着讲的就比较心凉凉了,先讲了堆,然后是hsah 栈,队列,链表问题都不大,笔记记得都还好,堆就凉凉了. 不会不会不会,没学 ...
- [USACO06NOV]糟糕的一天Bad Hair Day BZOJ 1660 单调栈
农民John的某 N 头奶牛 (1 <= N <= 80,000) 正在过乱头发节!由于每头牛都 意识到自己凌乱不堪的发型, FJ 希望统计出能够看到其他牛的头发的牛的数量. 每一头牛 i ...
- 洛谷P2866 [USACO06NOV]糟糕的一天Bad Hair Day
P2866 [USACO06NOV]糟糕的一天Bad Hair Day 75通过 153提交 题目提供者洛谷OnlineJudge 标签USACO2006云端 难度普及/提高- 时空限制1s / 12 ...
- 洛谷 P2866 [USACO06NOV]糟糕的一天Bad Hair Day
题目描述 Some of Farmer John's N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self ...
- 洛谷——P2866 [USACO06NOV]糟糕的一天Bad Hair Day
https://www.luogu.org/problem/show?pid=2866 题目描述 Some of Farmer John's N cows (1 ≤ N ≤ 80,000) are h ...
随机推荐
- 机器学习框架ML.NET学习笔记【2】入门之二元分类
一.准备样本 接上一篇文章提到的问题:根据一个人的身高.体重来判断一个人的身材是否很好.但我手上没有样本数据,只能伪造一批数据了,伪造的数据比较标准,用来学习还是蛮合适的. 下面是我用来伪造数据的代码 ...
- WCF 内置绑定在不同的传输安全模式下的信道层
basicHttpBinding Transport安全模式信道层 Message安全模式信道层 TransportWithMessageCredential安全模式信道层 TransportCred ...
- Servlet高级部分Listener
监听器的使用场景: ①:统计在线人数 ②:实现单一登录[一个账号只能在一台机器上登录] Servlet中的8大监听器: 1. ServletContextListener [接口方 ...
- sonarque下载和安装使用
参考地址: https://www.cnblogs.com/qiumingcheng/p/7253917.html https://www.cnblogs.com/cjsblog/p/10735800 ...
- fancyBox高级进阶用法
最近给客户做的一个项目中,客户要求弹窗的边界与页面某个区块边界平齐,但平齐之后,弹出的窗口就不是居中的情况了,研究之后,认为需要改写fancyBox的fancybox-wrap类中的top属性才能达到 ...
- Spring IoC和AOP的介绍
基于Spring Framework 版本:5.0.2.RELEASE IoC 概念:传统Java开发中,程序通过new主动创建对象实例,而Spring有专门的IoC容器来创建对象,具体来说就是在Sp ...
- 自己实现的简单的grid
12年在第一家公司的时候,有过很长一段时间在前端的使用研究上.一开始的时候使用ExtJs4.0 MVC 来开发前端,觉得里面的风转的组件非常好用,Panel.window.tree等等,简化了对于前端 ...
- C++,C++编程,Windows编程,MFC
编程 我们日常生活中接触到的电子类产品中的应用都是由编程而来 为什么编程,偷懒 我们通过编程驱使(指挥,命令)的是电信号 为什么上面说编程是偷懒,电的发现,给人们带来了便利,人们在各个方面驱使(换成“ ...
- Html+css实现带图标的控件
</pre><pre name="code" class="html"><!DOCTYPE html> <html l ...
- Extjs4.1+desktop+SSH2 定义程序入口
app.js定义程序入口: MainController.js: 加载控制器: 外部组件引用入口loader.js 时间组件 静态变量组件: 引入comm.js index.jsp 验证打印 comm ...