#CCBCHBON0000017. Bỏ qua giá trị âm trước khi cộng (Skip Negatives Before Summing)
Bỏ qua giá trị âm trước khi cộng (Skip Negatives Before Summing)
Skip Negatives Before Summing
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Compute the sum of only nonnegative entries () among integers. Zero is valid. Print 0 for an empty sequence or when all entries are negative.
Input
First (), followed by exactly integers in .
Output
Print the sum as a signed 64-bit integer.
Subtasks
-
Subtask 1 (20%): ; .
-
Subtask 2 (30%): ; .
-
Subtask 3 (50%): ; .
Examples
Example 1
Input:
4
-3 0 8 -2
Output:
8
Explanation:
Keep nonnegative values [0, 8]; their sum is 8.
Example 2
Input:
3
-4 -2 -1
Output:
0
Explanation:
Keep nonnegative values []; their sum is 0.