Блог пользователя tsminh_3

Автор tsminh_3, история, 11 лет назад, По-английски
Please help me with this 

Give n ropes, each rope in length a[i] (n<=10^3). Then divide them into two group
- Sum1 = sum of all ropes in group 1
- Sum2 = sum of all ropes in group 2 
The task asked if there is a way to divide them into two group which S1=S2`
Note : the numbers of rope in each group maybe not equal to the other

Sorry for my bad at English :(
  • Проголосовать: нравится
  • -21
  • Проголосовать: не нравится

»
11 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by tsminh_3 (previous revision, new revision, compare).

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

What is the size of array a?

»
11 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

sum all the elements of the array . if sum is odd print no otherwise find subset sum of sum/2 if this exist . B-)

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Can you please give me the link of this question?

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +19 Проголосовать: не нравится

According to Wiki Link , this problem is NP-complete and has pseudo-polynomial (O(n*sum)) time dp solution which is feasible only when sum is small. Hence, it would be nice if you could give a link to problem so that people can verify that your description and/or constraints about the problem are accurate.

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

This is basically the subset sum problem, and it's NP-complete, so you can't expect to solve it in polynomial time. If values were smaller (maybe  ≤ 105), you could do DP.