#CCBCHHAI0000025. Hai số dương hợp lệ liên tiếp (Two Consecutive Positive Values)
Hai số dương hợp lệ liên tiếp (Two Consecutive Positive Values)
Two Consecutive Positive Values
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Read integers in order. Stop at the first occurrence of two positive integers in two adjacent reads. Zero or a negative value breaks the streak. Print the number of reads and the sum of the two positive values that caused termination.
Input
A sequence of 2 to 10000 integers in . At least one pair of adjacent positive values exists, and its second member is the final input integer.
Output
Print two space-separated integers: the number of reads and the sum of the terminating adjacent positive pair.
Subtasks
- Subtask 1 (20%): At most integers in .
- Subtask 2 (30%): At most integers in .
- Subtask 3 (50%): At most integers in .
Examples
Example 1
Input
2 -1 3 4
Output
4 7
Explanation
2 starts a positive streak, -1 resets it; 3 and 4 are adjacent positives. Four reads, sum seven.
Example 2
Input
5 0 6 7
Output
4 13
Explanation
Zero interrupts the streak. The first adjacent positive pair is 6 and 7, after four reads.