ur boy needo
2007-10-30 13:36:11 UTC
A file contains a list of integers. The integers can, and are likely to, contain a mix of positive and negative values. The name of the file comes into your program via argv[1].
The first n numbers of the file are read by your program. The number n comes into your program via argv[2]. The number n will be no greater than 200,000.
For example, the file could contain the values:
-3 100 -4 -2 9 –63 -200 55
Your program will output a number that is the largest sum found in a subvector of this list. In the example above, the output would be 103 since that is the largest sum that can be formed by adding the elements of any subvector.
A subvector can be the entire list, a single member of the list, or it can be any collection of adjacent numbers. If the entire list of numbers contains negative numbers then your program should output 0.
Here is another example: 1 4 3 -4 8
The answer in this case would be 12 since the entire list of numbers forms the maximum sum.