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 $w_i$. 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 $w_i$. ### 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 \leq n, T, \sum{w_i} \leq 10^6$. ### Example Input: ``` 5 20 4 3 3 4 4 ``` Output: ``` 00110111011101100100 ```