#CCBCHMOT0000020. Đọc EOF không có dấu dừng (Sum Positive Values Until EOF)
Đọc EOF không có dấu dừng (Sum Positive Values Until EOF)
Sum Positive Values Until EOF
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Read integers until end-of-file without any sentinel. Sum strictly positive values; ignore negative values and zeros. Empty input has sum zero.
Input
A possibly empty whitespace-separated stream of integers.
Output
Print the sum of strictly positive values as a 64-bit integer.
Subtasks
- Subtask 1 (20%): At most 5 values, each in [-10,10].
- Subtask 2 (30%): At most 200 values, each in [-1000,1000].
- Subtask 3 (50%): At most 100000 values, each in [-10000,10000].
Examples
Example 1
Input
-2 3 0 7
Output
10
Explanation
Only 3 and 7 are positive, giving 10; EOF ends the loop.
Example 2
Input
Output
0
Explanation
Empty input causes the first read to fail; the sum stays zero.