MAIN72 - Subset sum
You are given an array of N integers. Now you want to find the sum of all those integers which can be expressed as the sum of at least one subset of the given array.
Input
First line contains T the number of test case. then T test cases follow, first line of each test case contains N (1 <= N <= 100) the number of integers, next line contains N integers, each of them is between 0 and 1000 (inclusive).
Output
For each test case print the answer in a new line.
Example
Input: 2 2 0 1 3 2 3 2 Output: 1 21
hide comments
sneh sajal:
2015-12-26 10:59:31
good Dp :) |
|
gullu_mishra:
2015-11-06 00:40:08
AC in 1 go..learned concept of subset sum using dp :) century 100th ;) |
|
eightnoteight:
2015-10-26 16:31:08
TLE for set; AC for unordered_set |
|
rini22:
2015-09-29 23:02:40
Easy |
|
aeon:
2015-08-17 15:28:03
Power of dp works again.. But careful with array size :) |
|
utkarsh agarwal:
2015-07-19 15:25:46
any tricky cases??
|
|
jaikishan:
2015-06-18 00:07:47
good problem
|
|
r0bo_dart:
2015-06-16 15:12:56
AC at first go :D |
|
i_am_looser:
2015-05-30 08:31:08
2 tle 2 wa but finally done using set.....stl rocks.... |
|
Anirudh Gupta:
2015-05-27 06:26:28
sigsegv on spoj but its running fyn on spoj.....plz help :( |
Added by: | Mahesh Chandra Sharma |
Date: | 2011-03-13 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own problem used for NSIT-IIITA main contest #7 |