CF731F.Video Cards
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Little Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course, Vlad immediately bought only to find out his computer is too old for the new game and needs to be updated.
There are n video cards in the shop, the power of the i-th video card is equal to integer value a__i. As Vlad wants to be sure the new game will work he wants to buy not one, but several video cards and unite their powers using the cutting-edge technology. To use this technology one of the cards is chosen as the leading one and other video cards are attached to it as secondary. For this new technology to work it's required that the power of each of the secondary video cards is divisible by the power of the leading video card. In order to achieve that the power of any secondary video card can be reduced to any integer value less or equal than the current power. However, the power of the leading video card should remain unchanged, i.e. it can't be reduced.
Vlad has an infinite amount of money so he can buy any set of video cards. Help him determine which video cards he should buy such that after picking the leading video card and may be reducing some powers of others to make them work together he will get the maximum total value of video power.
小弗拉德非常喜欢一款流行的电脑游戏《Bota-2》。最近,开发者宣布推出新扩展包《Bota-3》。当然,弗拉德立刻购买了它,却发现自己电脑太旧,无法运行这款新游戏,需要升级硬件。
商店里共有 n 块显卡,第 i 块显卡的性能为整数值 ai。由于弗拉德希望确保新游戏能顺利运行,他决定不只购买一块显卡,而是购买多块显卡,并利用前沿技术将它们的性能“联合”起来。该技术要求:从所购显卡中选定一块作为主卡(leading card),其余显卡则作为辅卡(secondary cards)。为使该技术生效,每块辅卡的性能必须能被主卡的性能整除。为达成此条件,任意一块辅卡的性能可被降低为不大于其当前性能的任意整数值;但主卡的性能必须保持不变(即不可降低)。
弗拉德拥有无限的资金,因此他可以购买任意组合的显卡。请帮助他确定应购买哪些显卡,使得在选定主卡、并可能降低部分辅卡性能以满足整除条件后,所有显卡的总性能之和达到最大值。
输入格式
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of video cards in the shop.
The second line contains n integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 200 000) — powers of video cards.
输入的第一行包含一个整数 n(1 ≤ n ≤ 200000)—— 商店中显卡的数量。
第二行包含 n 个整数 a1,a2,…,an(1 ≤ ai ≤ 200000)—— 显卡的性能值。
输出格式
The only line of the output should contain one integer value — the maximum possible total power of video cards working together.
输出仅包含一行,应为一个整数——即协同工作的显卡所能达到的最大总功率。
输入输出样例
输入#1
4 3 2 15 9
输出#1
27
输入#2
4 8 2 2 7
输出#2
18
说明/提示
In the first sample, it would be optimal to buy video cards with powers 3, 15 and 9. The video card with power 3 should be chosen as the leading one and all other video cards will be compatible with it. Thus, the total power would be 3 + 15 + 9 = 27. If he buys all the video cards and pick the one with the power 2 as the leading, the powers of all other video cards should be reduced by 1, thus the total power would be 2 + 2 + 14 + 8 = 26, that is less than 27. Please note, that it's not allowed to reduce the power of the leading video card, i.e. one can't get the total power 3 + 1 + 15 + 9 = 28.
In the second sample, the optimal answer is to buy all video cards and pick the one with the power 2 as the leading. The video card with the power 7 needs it power to be reduced down to 6. The total power would be 8 + 2 + 2 + 6 = 18.
在第一个样例中,最优方案是购买显卡,其性能分别为 3、15 和 9。应选择性能为 3 的显卡作为主显卡,其余所有显卡均与此主显卡兼容。因此总性能为 3 + 15 + 9 = 27。若购买全部显卡并选择性能为 2 的显卡作为主显卡,则其余所有显卡的性能均需减少 1,此时总性能为 2 + 2 + 14 + 8 = 26,小于 27。请注意,不允许降低主显卡的性能,即不能得到总性能 3 + 1 + 15 + 9 = 28。
在第二个样例中,最优方案是购买全部显卡,并选择性能为 2 的显卡作为主显卡。性能为 7 的显卡需将其性能降至 6。此时总性能为 8 + 2 + 2 + 6 = 18。
输入解题思路,AI测评打分。不知道怎么写?