TOJ 3425: Generic Cow Protests -- 树状数组
来源:互联网 发布:linux命令入门 编辑:程序博客网 时间:2024/06/13 05:31
3425: Generic Cow Protests
Total Submit: 46 Accepted:14
Description
Farmer John's N (1 <= N <= 100,000) cows are lined up in a row and numbered 1..N. The cows are conducting another one of their strange protests, so each cow i is holding up a sign with an integer A_i
(-10,000 <= A_i <= 10,000).
FJ knows the mob of cows will behave if they are properly grouped and thus would like to arrange the cows into one or more contiguous groups so that every cow is in exactly one group and that every
group has a nonnegative sum.
Help him count the number of ways he can do this, modulo 1,000,000,009.
By way of example, if N = 4 and the cows' signs are 2, 3, -3, and 1, then the following are the only four valid ways of arranging the cows:
(2 3 -3 1)
(2 3 -3) (1)
(2) (3 -3 1)
(2) (3 -3) (1)
Note that this example demonstrates the rule for counting different orders of the arrangements.
Input
* Line 1: A single integer: N
* Lines 2..N + 1: Line i + 1 contains a single integer: A_i
Output
* Line 1: A single integer, the number of arrangements modulo 1,000,000,009.
Sample Input
423-31
Sample Output
4
Source
USACO Feb 2011
http://www.verydemo.com/demo_c427_i28080.html 有详细的解答
- TOJ 3425: Generic Cow Protests -- 树状数组
- SicilyOJ(SOJ) 5228 Generic Cow Protests(dp+离散化+树状数组优化)
- [Usaco2011 Feb]Generic Cow Protests
- bzoj 2274 [Usaco2011 Feb]Generic Cow Protests
- bzoj2274[Usaco2011 Feb]Generic Cow Protests
- 2274: [Usaco2011 Feb]Generic Cow Protests
- Generic Cow Protests-G——60分做法
- Cow Sorting (树状数组)
- 树状数组 hdu2838 Cow Sorting
- HDU2838 Cow Sorting 树状数组
- hdu2838 Cow Sorting(树状数组)
- hdu2838 Cow Sorting 树状数组
- HDU2838 Cow Sorting (树状数组)
- toj 3505. Naughty Mike(树状数组)
- TOJ 4354 HDU 4262 Juggler / 树状数组
- TOJ 4074 Running Laps -- 树状数组
- 【TOJ 3401.】Disharmony Trees【树状数组】
- TOJ 3852 Haitang1 三维树状数组
- 自然语言处理公开课
- 云服务
- 2011 ACM-ICPC 成都赛区A题 Alice and Bob (博弈动规)
- Spark 0.9的安装配置
- C++之构造函数与初始化列表
- TOJ 3425: Generic Cow Protests -- 树状数组
- android设计模式之建造者模式
- 传日本推演钓鱼岛冲突:称必须为出兵松绑
- 十五个说话用脑、做事慎言的技巧
- 基于 控制台 简易 学生信息管理系统 (增、删、改)
- 栈与队列的使用
- Java Card Applet Development——环境搭建及基础概念
- 关于“C++primer plus第六版课后编程题答案”18章的说明
- 2014年4月份的所有公告中有股权激励计划的股票一览