#P5365. [SNOI2017] 英雄联盟
[SNOI2017] 英雄联盟
Problem Description
Xiao Piqiu, who is in college, loves the game League of Legends, but he plays very poorly, so online players jokingly call him an “elementary school kid”.
Now, Xiao Piqiu finally cannot stand the ridicule anymore and decides to become stronger. His way to become stronger is: buying skins.
Xiao Piqiu can only play champions, so he only plans to buy skins for these champions, and he decides that in the future he will only play champions that have skins.
Among these champions, the -th champion has skins, and the price is Q-coins per skin (skins of the same champion have the same price).
To make himself look more impressive, Xiao Piqiu decides to show his skins to his classmates. The idea is: for each champion that has skins, randomly choose one skin to show.
For example, Xiao Piqiu has champions, and these champions have skins respectively. Then Xiao Piqiu has ways to show them.
Now, Xiao Piqiu wants the number of his showing strategies to be at least . How much money does he need to spend at least?
Input Format
The first line contains two integers .
The second line contains integers, representing the number of skins for each champion .
The third line contains integers, representing the price of each champion’s skins .
Output Format
One integer, representing the minimum cost for Xiao Piqiu to reach the goal.
3 24
4 4 4
2 2 2
18
Hint
Sample Explanation
Each champion has skins, and each skin costs Q-coins. Then for each champion, buy skins: . The total cost is Q-coins.
Constraints
There are test cases in total. For the -th test case: .
For of the testdata: . A solution is guaranteed to exist.
Translated by ChatGPT 5