Your code is a bit too long to analyze in full, but it seems your algorithm for assigning planes to runways is off. Your program currently assigns planes like this:
planes 10 (1,1,1,3,3,1,2,2,2,2)
runways 5 (2 2 3 5 7)
capacity (2 2 2 2 2)
Result 5
Time table: ('-' indicates occupied by plane, 'x' indicates last plane left)
runway:|0 1 2 3 4
-------+-+-+-+-+-
time 0:|2 2 2 2 1
time 1:|- - - - 3
time 2:|1 1 3 1 -
time 3:|x x - x -
time 4:| - x
time 5:| x
I'm not sure how you decide what plane to assign to which runway, but there is room for optimization.
I suggest the following algorithm for assigning planes to runways:
1. Determine the highest runway time from all currently unoccupied runways
2. Find the plane with the highest time no larger than this from the list of planes
3. Find the runway with the lowest runway time >= plane time from unoccupied runways
4. assign plane to this runway
This should yield a result of 4 with the following time table:
runway:|0 1 2 3 4
-------+-+-+-+-+-
time 0:|2 2 3 3 2
time 1:|- - - - -
time 2:|2 1 - - 1
time 3:|- x 1 1 x
time 4:|x x x
Note that this algorithm will not always deliver the best results - I fear that you'd have to test all possible combinations to make sure you always find the best solution. But this algorithm should work well for most cases.
If you want the best algorithm, write a function to enumerate all possible combinations and another to evaluate any given combination. Then test each combination to find the best one.