#CCBOTPBA0000003. Tổng số dương và số âm (Positive and Negative Sums)
Tổng số dương và số âm (Positive and Negative Sums)
Positive and Negative Sums
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given n integers, compute separately the sum of strictly positive numbers and the sum of strictly negative numbers; zero belongs to neither group.
Input
An integer n, then n integers a_i.
Output
Print positive_sum negative_sum on one line; an empty group has sum zero.
Subtasks
-
Subtask 1 (20%):
n ≤ 20,|a_i| ≤ 100. -
Subtask 2 (30%):
n ≤ 1000,|a_i| ≤ 10^6. -
Subtask 3 (50%):
n ≤ 100000,|a_i| ≤ 10^6.
Examples
Example 1
Input:
5
-2 0 3 -4 1
Output:
4 -6
Explanation: Positive sum is 3+1=4; negative sum is -2+(-4)=-6.
Example 2
Input:
0
Output:
0 0
Explanation: Both groups are empty.