Knapsack - MarisaOJ: Marisa Online Judge

Knapsack

Time limit: 5000 ms
Memory limit: 256 MB
Given n objects, where the i-th object has a weight of wi. For each weight k from 1 to T, determine whether there is a way to select some objects out of the n objects such that their total weight is k. ### Input - The first line contains two integers n and T. - The second line contains n integers wi. ### Output - Print a binary string of length T, where the i-th character is 0 or 1 indicating whether it's impossible or possible to achieve weight i. ### Constraints - 1≤n,T,∑wi≤106. ### Example Input: 52043344 Output: 00110111011101100100