Submit | All submissions | Best solutions | Back to list |
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
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 |
hide comments
|
|||||||||
2018-08-02 16:52:36
One minor bug fu***d me left and right for an hour. OMG finally AC in one go..! |
|||||||||
2018-07-19 17:30:54
impossible |
|||||||||
2018-07-15 12:11:20
Learnt a lot from this one ! |
|||||||||
2018-07-12 13:43:12
maximum number of test cases? |
|||||||||
2018-03-05 14:43:10
easy dp |
|||||||||
2017-12-30 12:17:07
nice dp :) took a while but worth it |
|||||||||
2017-09-03 22:28:05
Problem is ambiguous!You have to caculate total sum of each subset whose sum is distinct :) |
|||||||||
2017-07-04 17:15:19
0.01s |
|||||||||
2017-06-24 08:17:50
Direct application of subset sum using dp concept!! Without I/O optimizations= AC 0.03 With I/O optimization= AC 0.02 |
|||||||||
2017-06-22 20:07:18
Just DP...No need for unordered set whatsoever :) |