A team of k workers should paint a fence which contains N planks numbered from 1 to N from left to right. Each worker i should sit in front of the plank Si and he may paint only a compact interval . This interval should contain the Si plank. Also a worker should not paint more than Li planks and for each painted plank he should receive PiP_i Pi. A plank should be painted by no more than one worker. All the numbers Si should be distinct. Being the team's leader you want to determine for each worker the interval that he should paint, knowing that the total income should be maximal. The total income represents the sum of the workers personal income. Write a program that determines the total maximal income obtained by the K workers.
A team of k (1≤K≤100)(1 leq K leq 100)(1≤K≤100) workers should paint a fence which contains N (1≤N≤16000)(1 leq N leq 16 000)(1≤N≤16000) planks numbered from 1 to N from left to right. Each worker i (1≤i≤K)(1 leq i leq K)(1≤i≤K)should sit in front of the plank Si and he may paint only a compact interval (this means that the planks from the interval should be consecutive). This interval should contain the Si plank. Also a worker should not paint more than Li planks and for each painted plank he should receive Pi(1≤Pi≤10000)P_i (1 leq P_i leq 10 000)Pi(1≤Pi≤10000). A plank should be painted by no more than one worker. All the numbers Si should be distinct. Being the team's leader you want to determine for each worker the interval that he should paint, knowing that the total income should be maximal. The total income represents the sum of the workers personal income. Write a program that determines the total maximal income obtained by the K workers.