Given the count of digits 1, 2, 3, 4. Using these digits you are allowed to only form numbers 234 and 12. The task is to find the maximum possible sum that can be obtained after forming the numbers.
Note: The aim is only to maximize the sum, even if some of the digits left unused.
Input : c1 = 5, c2 = 2, c3 = 3, c4 = 4 Output : 468 Explanation : We can form two 234s Input : c1 = 5, c2 = 3, c3 = 1, c4 = 5 Output : 258 Explanation : We can form one 234 and two 12s
Approach : An efficient approach is to first try to make 234’s. The possible number of 234s are minimum of c2, c3, c4. After this, with remaining 1’s and 2’s try to form 12s.
Below is the implementation of the above approach :
- Count numbers in given range such that sum of even digits is greater than sum of odd digits
- Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
- Find smallest number with given number of digits and sum of digits under given constraints
- Find smallest number with given number of digits and sum of digits
- Find the Largest number with given number of digits and sum of digits
- Minimum digits to be removed to make either all digits or alternating digits same
- Find smallest possible Number from a given large Number with same count of digits
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Numbers with sum of digits equal to the sum of digits of its all prime factor
- Sum of the digits of square of the given number which has only 1's as its digits
- Find the average of k digits from the beginning and l digits from the end of the given number
- Maximize the given number by replacing a segment of digits with the alternate digits given
- Maximum XOR value of maximum and second maximum element among all possible subarrays
- Find maximum sum possible equal sum of three stacks
- Count of n digit numbers whose sum of digits equals to given sum
- Find two numbers with given sum and maximum possible LCM
- Maximum possible time that can be formed from four digits
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Count of numbers upto N digits formed using digits 0 to K-1 without any adjacent 0s
- Maximum sum possible from given Matrix by performing given operations
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.