{"problem":{"name":"B. Anton and Digits","description":{"content":"Recently Anton found a box with digits in his room. There are _k_2 digits 2, _k_3 digits 3, _k_5 digits 5 and _k_6 digits 6. Anton's favorite integers are 32 and 256. He decided to compose this integ","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF734B"},"statements":[{"statement_type":"Markdown","content":"Recently Anton found a box with digits in his room. There are _k_2 digits 2, _k_3 digits 3, _k_5 digits 5 and _k_6 digits 6.\n\nAnton's favorite integers are 32 and 256. He decided to compose this integers from digits he has. He wants to make the sum of these integers as large as possible. Help him solve this task!\n\nEach digit can be used no more than once, i.e. the composed integers should contain no more than _k_2 digits 2, _k_3 digits 3 and so on. Of course, unused digits are not counted in the sum.\n\n## Input\n\nThe only line of the input contains four integers _k_2, _k_3, _k_5 and _k_6 — the number of digits 2, 3, 5 and 6 respectively (0 ≤ _k_2, _k_3, _k_5, _k_6 ≤ 5·106).\n\n## Output\n\nPrint one integer — maximum possible sum of Anton's favorite integers that can be composed using digits from the box.\n\n[samples]\n\n## Note\n\nIn the first sample, there are five digits 2, one digit 3, three digits 5 and four digits 6. Anton can compose three integers 256 and one integer 32 to achieve the value 256 + 256 + 256 + 32 = 800. Note, that there is one unused integer 2 and one unused integer 6. They are not counted in the answer.\n\nIn the second sample, the optimal answer is to create on integer 256, thus the answer is 256.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"最近，Anton 在他的房间里发现了一个装有数字的盒子。盒中有 #cf_span[k2] 个数字 #cf_span[2]，#cf_span[k3] 个数字 #cf_span[3]，#cf_span[k5] 个数字 #cf_span[5]，以及 #cf_span[k6] 个数字 #cf_span[6]。\n\nAnton 最喜欢的整数是 #cf_span[32] 和 #cf_span[256]。他决定用他拥有的数字来组成这些整数，并希望使这些整数的和尽可能大。请帮助他解决这个问题！\n\n每个数字最多只能使用一次，即组成的整数中包含的数字 #cf_span[2] 不超过 #cf_span[k2] 个，数字 #cf_span[3] 不超过 #cf_span[k3] 个，依此类推。未使用的数字不计入总和。\n\n输入的唯一一行包含四个整数 #cf_span[k2], #cf_span[k3], #cf_span[k5] 和 #cf_span[k6] —— 分别表示数字 #cf_span[2]、#cf_span[3]、#cf_span[5] 和 #cf_span[6] 的数量（#cf_span[0 ≤ k2, k3, k5, k6 ≤ 5·106]）。\n\n请输出一个整数 —— 使用盒子中的数字所能组成的 Anton 最喜欢的整数的最大可能和。\n\n在第一个样例中，有五个数字 #cf_span[2]，一个数字 #cf_span[3]，三个数字 #cf_span[5] 和四个数字 #cf_span[6]。Anton 可以组成三个整数 #cf_span[256] 和一个整数 #cf_span[32]，得到总和 #cf_span[256 + 256 + 256 + 32 = 800]。注意，还有一个未使用的数字 #cf_span[2] 和一个未使用的数字 #cf_span[6]，它们不计入答案。\n\n在第二个样例中，最优解是组成一个整数 #cf_span[256]，因此答案为 #cf_span[256]。\n\n## Input\n\n输入的唯一一行包含四个整数 #cf_span[k2], #cf_span[k3], #cf_span[k5] 和 #cf_span[k6] —— 分别表示数字 #cf_span[2]、#cf_span[3]、#cf_span[5] 和 #cf_span[6] 的数量（#cf_span[0 ≤ k2, k3, k5, k6 ≤ 5·106]）。\n\n## Output\n\n请输出一个整数 —— 使用盒子中的数字所能组成的 Anton 最喜欢的整数的最大可能和。\n\n[samples]\n\n## Note\n\n在第一个样例中，有五个数字 #cf_span[2]，一个数字 #cf_span[3]，三个数字 #cf_span[5] 和四个数字 #cf_span[6]。Anton 可以组成三个整数 #cf_span[256] 和一个整数 #cf_span[32]，得到总和 #cf_span[256 + 256 + 256 + 32 = 800]。注意，还有一个未使用的数字 #cf_span[2] 和一个未使用的数字 #cf_span[6]，它们不计入答案。在第二个样例中，最优解是组成一个整数 #cf_span[256]，因此答案为 #cf_span[256]。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ k_2, k_3, k_5, k_6 \\in \\mathbb{Z}_{\\geq 0} $ denote the counts of digits $ 2, 3, 5, 6 $ respectively.  \n\nLet $ x \\in \\mathbb{Z}_{\\geq 0} $ be the number of integers $ 256 $ formed.  \nLet $ y \\in \\mathbb{Z}_{\\geq 0} $ be the number of integers $ 32 $ formed.  \n\n**Constraints**  \n1. $ x \\leq \\min(k_2, k_5, k_6) $  \n2. $ y \\leq \\min(k_2 - x, k_3) $  \n3. $ x, y \\geq 0 $  \n\n**Objective**  \nMaximize the total sum:  \n$$\nS = 256x + 32y\n$$","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF734B","tags":["brute force","greedy","implementation","math"],"sample_group":[["5 1 3 4","800"],["1 1 1 1","256"]],"created_at":"2026-03-03 11:00:39"}}