logo AlgoBeat OnlineJudge
登录 注册

#200560. [USACO ?] Generic Cow Protests [Source Request]

内存限制:125 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Farmer John’s cows gather and line up in a row to stage a protest. The -th cow has a rationality value .

He wants the cows to remain rational; to that end, he plans to partition all the cows into several groups such that within each group the sum of rationality values is at least zero.

Since the cows are arranged in a straight line, each group must be a contiguous segment. Please help John compute the maximum number of groups.

输入格式

The first line contains a positive integer , the number of cows.

The next lines each contain one integer, the rationality value of each cow.

输出格式

If a valid partition exists, output one line with a single integer, the answer; otherwise output Impossible.

样例

样例输入 1

4
2
3
-3
1

样例输出 1

3

数据范围与提示

Constraints

  • For 30% of the testdata, .
  • For 100% of the testdata, , .

Translated by ChatGPT 5