#CCBCHMOT0000018. Số phần tử trước số âm (Count Values Before First Negative)
Số phần tử trước số âm (Count Values Before First Negative)
Count Values Before First Negative
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Read integers until the first negative integer, which marks the end. All preceding values are nonnegative, including zero. Count the values before the terminator, excluding the negative value.
Input
A sequence of integers terminated by its first negative value.
Output
Print the number of nonnegative values before the first negative.
Subtasks
- Subtask 1 (20%): At most 5 values in [0,10], terminator in [-10,-1].
- Subtask 2 (30%): At most 200 values in [0,10000], terminator in [-10000,-1].
- Subtask 3 (50%): At most 100000 values in [0,1000000], terminator in [-1000000,-1].
Examples
Example 1
Input
0 7 -1
Output
2
Explanation
Zero and seven both count; -1 terminates the sequence.
Example 2
Input
-5
Output
0
Explanation
The first value is the terminator, so the answer is zero.