시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 26 | 14 | 12 | 54.545% |
Farmer John has a long fence made of fence poles and rails. Each of the N (1 ≤ N ≤ 3000) fence poles carries a sign with a single number from -1000 through +1000. Some poles might have the same number on their sign as other poles. While chewing their cud, the cows made up a game. The cow who can find the "best fence sum" gets ice cream for dessert.
To win the game, the winning cow must find the longest contiguous set of poles whose sum has the smallest absolute value. Help them determine the winning sum.
A single line with three numbers:
If more than one sequence has the same "best fence sum" and same maximum length, report the sequence with the lowest first sequence number.
6 5 10 -5 -6 2 4
4 6 0