report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
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 ```
Square root decomposition
Frequency
Tree query
Inversions query
Nearest vertex
Dominating color
String occurences 3
Inversions query 2
Pair
Sparse update
Tree
Range query
String concatenation
Subarray distance
Chameleon
Knapsack
Bit counting
Subsequence queries
Sub-subsequence
Delete numbers
Mode
Marisa is happy
Inversions query 3
Upperbound
23 path
Yet another square root decomposition problem
Marisa plays poker
Wonderful world
Topic
Dynamic Programming
Rating 2000
Solution (1) Solution