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.


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).  


For each test case print the answer in a new line.


0 1
2 3 2


hide comments
dkkv0000: 2020-01-21 11:05:32

wow topdown(dp+unordered_set)

pratiyush_05: 2019-08-05 15:15:42

My first dp problem.....accepted ...yeah

Last edit: 2019-08-05 15:16:03
sky_scraper: 2019-06-05 09:30:44

Iterative - set/unordered set -> AC
Even if you like recursive solution try the iterative one and vice versa.

Last edit: 2019-06-05 09:31:55
abhinav_kr: 2019-05-22 20:01:04

Unordered_set + Memoization + fast I/O : AC 0.06s

demon8778: 2018-11-22 08:59:19

Guys!! Need help here. I have solved this problem but it took me about 4 hours. can anyone please help how do I improve my speed for solving problems?

kalyanavuthu: 2018-08-02 16:52:36

One minor bug fu***d me left and right for an hour. OMG finally AC in one go..!

paroaro: 2018-07-19 17:30:54


vishwanath_26: 2018-07-15 12:11:20

Learnt a lot from this one !

sharansh12: 2018-07-12 13:43:12

maximum number of test cases?

hacker920: 2018-03-05 14:43:10

easy dp

Added by:Mahesh Chandra Sharma
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