Link: http://www.spoj.com/problems/MINUS/

I have an Idea, after doing n-1 operations one can see that there is just + and - coefficients before each number that matters. For eg. given sequence: 12 10 4 3 5 and we need to make it a mathematical expression using + and - signs only to get 4 ,one solution will be +12-10+4+3-5 = 4 ,this expression (+12-10+4+3-5) is get by using knapsack dp, so the exact sign sequence (+)12(-)10(+)4(+)2(-)5 i.e. +-++- is the required signs sequence and at first stage (+)12(+)10(+)4(+)3(+)5 i.e. +++++ how to get +-++- and what should be sequence of operations?

  • 2
    $\begingroup$ The question should be self-contained. What is your question exactly? $\endgroup$ – Evil Jun 17 '17 at 12:42
  • $\begingroup$ I don't know how to get sequence of operations on converting sequence +++++ to +-++- $\endgroup$ – Śȟůbȟäm Ŗäĵpůț Jun 17 '17 at 13:14
  • $\begingroup$ how to decide which sets too be merged at the moment ,say instead of (+)(+)(+)(+)(+) -> (+)(+-)(+)(+) If I do (+)(+)(+)(+)(+) ->(+-)(+)(+)(+) ->(+-)(+)(+-) answer woudnt be same as operations are less than n-1. $\endgroup$ – Śȟůbȟäm Ŗäĵpůț Jun 17 '17 at 13:14
  • 1
    $\begingroup$ Could you edit your question to include that info? Also the self-contained means that the body of the question should be in your post, not in any external server. $\endgroup$ – Evil Jun 17 '17 at 13:43
  • $\begingroup$ I want to make it as clear as possible but plz read this answer also: quora.com/… $\endgroup$ – Śȟůbȟäm Ŗäĵpůț Jun 18 '17 at 4:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.