ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2199. Company Question

Is sample correct?
Posted by Oleg Alexeev 20 Jan 2025 03:37
Why for Q: 1 6 the answer is 5 6 and not 2 6 ?

Having input "17 11 -1 -4 20 -24"
for 5 6 we have 20 -24 = -4
and for 2 6 we have 11 -1 -4 +20 -24 = 2
why -4 is better than 2?
Re: Is sample correct?
Posted by Oleg Vasilenko (Chelyabinsk) 20 Jan 2025 22:21
Because we need to find 2 separate indexes i < j :  |a[i] + a[j]| is minimal.
Not sum of segment |a[i]+a[i+1]+...+a[j]|, but only 2 numbers a[i] and a[j].