Equator
InterviewTime limit1sMemory limit256 MB
Each test case gives city profits around a circle and asks for the most profitable contiguous block, or zero when all are losses.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Array
- Solved
- No attempts yet
Problem
Cities lie on a circular equator. The gang may land once, travel in one direction, and rob a contiguous block of cities. Each city has a profit or loss. Find the maximum total profit, or 0 if they should not land at all.
Input
The first line contains . Each test case gives and integers .
Output
For each test case, print the maximum total profit.