For denominations and target , greedy selects , using three coins. The representation uses two coins and is optimal because there is no denomination six. Hence choosing the largest affordable coin is not generally optimal.
Write for , with a separate unit denomination. Choose, among all minimum-coin representations of the target, one whose vector of counts is lexicographically largest when larger denominations come first. Such a choice exists because a fixed positive target has only finitely many representations.
There cannot be two unit coins: replacing them by one decreases the count. For , two copies of can be exchanged usingThis keeps the coin count unchanged but increases the first differing larger-denomination count, contradicting the chosen lexicographic maximum. Thus there exists an optimal representation using at most one of each denomination below the largest. The largest denomination may repeat.
It remains to show why that normalization implies greedy optimality; uniqueness alone is not enough for an arbitrary coin system. Fix a denomination . Let be the total value of all coins smaller than in the chosen optimal representation, and let be their number. These smaller coins are distinct. If records the selected non-unit denominations, thenIf , replace all smaller coins by one and unit coins. The new number of coins iscontradicting optimality. Therefore the total value below every denomination is strictly less than .
At the largest denomination, this forces its count to be : its residual value is nonnegative and smaller than . Remove those coins. The same smaller-denomination property then forces the next quotient, and so on down to the unit coin. These are exactly greedy's choices, proving greedy is optimal for every positive target. The argument also covers , where the denominations are two and one. Independent comparison with coin-change dynamic programming confirmed the formula for all and targets from one to 2,000; that finite check supplements the proof.
Serve customers in nondecreasing service time, with ties broken arbitrarily. The objective in the source includes each customer's own service time, so these are completion times, not only delays before service begins. If the order is , thenTo prove optimality, consider adjacent service times after an elapsed time . Their contributions before an exchange are ; after the exchange they are . The total decreases by . Earlier customers are unaffected, and later customers begin after the same combined duration as before, so their completion times are unchanged.
Repeatedly exchanging adjacent inversions reaches a nondecreasing order without increasing the objective. Hence that order is optimal. Sorting takes time in a comparison model, followed by a linear traversal to produce the order or compute the total. Equal service times give zero exchange difference and do not affect optimality. If waiting time were instead defined before service, subtracting the order-independent total service time would give the same optimal order.
Articles by others on the same topic
There are currently no matching articles.