F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Divide the Sequence

Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 3431    Accepted Submission(s): 1328


Problem Description
Alice has a sequence A, She wants to split A into as much as possible continuous subsequences, satisfying that for each subsequence, every its prefix sum is not small than 0.
 

Input
The input consists of multiple test cases.
Each test case begin with an integer n in a single line.
The next line contains $n$ integers $A_{1},A_{2}\cdots A_{n}$.
$1 \leq n \leq 1e6$
$-10000 \leq A[i] \leq 10000$
You can assume that there is at least one solution.
 

Output
For each test case, output an integer indicates the maximum number of sequence division.
 

Sample Input
6 1 2 3 4 5 6 4 1 2 -3 0 5 0 0 0 0 0
 

Sample Output
6 2 5
 

Author
ZSTU
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-09 09:16:10, Gzip enabled