eolymp
bolt
Try our new interface for solving problems
Problems

Рюкзак с массами

Рюкзак с массами

Given $n$ items with mass $m_1, m_2, ..., m_n$ and cost $c_1, c_2, ..., c_n$ respectively. They fill the knapsack, that can withstand a weight of no more than $s$. Determine the set of items that can be carried in the knapsack that has the highest cost. \InputFile The first line contains a positive integer $s\:(s \le 10^4)$ --- the weight of the knapsack. The second line contains $n\:(n \le 100)$ positive integers $m_i\:(m_i \le 100)$ --- the weights of the items. The third line contains $n$ positive integers $c_i\:(c_i \le 100)$ --- the cost of the items. \OutputFile Print the numbers of items (numbers from $1$ to $n$) that will be included in the knapsack with the highest cost.
Time limit 1 second
Memory limit 128 MiB
Input example #1
6
2 4 1 2
7 2 5 1
Output example #1
1
3
4