Sunday, April 13, 2014

SPOJ 16121. MODIFY SEQUENCE (NITK06)

http://www.spoj.com/problems/NITK06/

   Here is how we need to approach this problem. Suppose there are 2 numbers, for finding the answer we need to check if the two are equal numbers or no. When there are 3, here is what we will need to do, we need to find the smaller of the elements in the ends (first and last) and decrease it to 0 and see and after that we can ignore him and the only thing which is left to check is the equality of the remaining 2 elements, this way we need to deal with all the cases, by checking every three, picking the smallest if it is on the end (first or last) and by making it 0 check the rest, overall this is the same as giving negative signs to the elements with the elements with the index divisible on 2 and counting the total sum, if the sum is 0 then the answer is "YES" otherwise the answer is "NO".


       DOWNLOAD THE FULL SOURCE CODE



 

No comments:

Post a Comment