Dynamic Programming or just simple technique

Revision en1, by ReadDead, 2019-03-20 23:24:14

Given K <= 100 types of sticks, each stick i having Li units of length, and Pi as prize of the stick and there is an unlimited amount of sticks from each type. We have to connect multiple sticks together so that total length of chosen sticks is exactly N.

I'm struggling to find any solution within the limits of the time limit — 1s, because of the length N which can reach up to 10^9. Can someone give me any techniques required to solve the problem(i know the solution with O(NK) time complexity-not good for time limit), or report if there aren't any.

Thank you :)

Tags #dp

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English ReadDead 2019-03-21 00:57:04 37 Tiny change: ' exactly N.\n\nI'm s' -> ' exactly N and total prize is small as possible.\n\nI'm s'
en1 English ReadDead 2019-03-20 23:24:14 626 Initial revision (published)