Project: Portfolio Selection · Score Dynamic Programming

Lesson 4

Nikolai Chukhin · Alexander S. Kulikov

Programming problem. Often we want not only the value of the optimal score, but also a portfolio that achieves it.

Implement a program for the same portfolio optimization problem, but output one optimal portfolio.

  • Input format.  The first line contains two integers \(1 \le n \le 80\) and \(1 \le B \le 1000\). The second line contains integers \(1 \le p_{1},\dotsc,p_{n} \le 100\). The third line contains integers \(1 \le r_{1},\dotsc,r_{n} \le 1000\).

  • Output format.  Output the indices of stocks in one optimal portfolio. Stocks are indexed by the elements of \([n]\). If the optimal portfolio is empty, output an empty line.

5 points
Public samples
Public sample 1
Input
4 10
2 3 5 7
1 4 5 6
Expected output
1 2 3
Public sample 2
Input
3 10
6 6 10
9 9 10
Expected output
3