First of all, we will generate all possible combinations of “aa”(0.50.5-liter bottle) and “bb”(11-liter bottle) by a nested loop and count the sum of liters of every combination in O(a×b)O(a\times b) complexity.
Now for each ii from 00 to cc, we will try to take ii number of 22 liters bottle. That is to say, for each ii, we will add the count of (n2×i)(n-2\times i) liters generated by the a,ba,b combination to the answer.

Statistics

95% Solution Ratio
TonimaEarliest, Nov '21
BruisedYetOkayFastest, 0.0s
Noshin_1703086Lightest, 131 kB
FrdhsnShortest, 283B
Toph uses cookies. By continuing you agree to our Cookie Policy.