Given an integer array that may contain positive and negative numbers, find the sum of the longest contiguous subarray consisting only of positive numbers. If multiple such subarrays share the maximum length, return the maximum sum among them. If the array contains no positive numbers, return 0. Explain the algorithm and its time and space complexity, and provide code in a language of your choice.