rausted
November 28th, 2006, 03:24 PM
I have a problem that I cannot solve! This problem is for a competition in Greece, so if you have any ideas please report before new years eve.
Here is the problem:
We want to built a stone monument or something, and we need to find the best amount of stones to do this. The input has in the first line two numbers
S=the area and N=the number of stones. All numbers are in integer limits.
the lines 2 to n+1 have one number which is the area of each stone. Please find me an algorithm faasstt! Its similar to knapsack problem because the less stones are used the better, but its different because the final result must be the closest to S sum of stone areas. Any ideas are welcome! Start posting whatever you think!
sample input: the_wall.in
10 100
40
22
11
20
9
8
6
2
3
4
solution: 40+22+11+20+4+3
Here is the problem:
We want to built a stone monument or something, and we need to find the best amount of stones to do this. The input has in the first line two numbers
S=the area and N=the number of stones. All numbers are in integer limits.
the lines 2 to n+1 have one number which is the area of each stone. Please find me an algorithm faasstt! Its similar to knapsack problem because the less stones are used the better, but its different because the final result must be the closest to S sum of stone areas. Any ideas are welcome! Start posting whatever you think!
sample input: the_wall.in
10 100
40
22
11
20
9
8
6
2
3
4
solution: 40+22+11+20+4+3