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

Common Board

Problem with sum of sequence
Posted by Wojtek Jamrozy 4 Apr 2006 19:22
I have problem to solve:
There is a set of N integers in range [-1000, 1000], N< 1000
I have to find if there is any subset which sum of elements is exactly S.
S is an integer in range [-1 000 000, 1 000 000 ]

Example:

Set - {5, 10, 25, 50}
S = 30
I can find a subset {5,25} - 5+25 = 30

Set - { -6,9,100,-45}
S = -42
I can find a subset {-6,9,-45} - (-6)+9+(-45) = 3 + (-45) = (-42)

Set - {-5, 10, 20, 100}
Set = 3
I can't find any set which sum is exacly 3.

Please help