#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 NN champions, so he only plans to buy skins for these NN champions, and he decides that in the future he will only play champions that have skins.

Among these NN champions, the ii-th champion has KiK_i skins, and the price is CiC_i 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 55 champions, and these 55 champions have 0,0,3,2,40, 0, 3, 2, 4 skins respectively. Then Xiao Piqiu has 3×2×4=243 \times 2 \times 4 = 24 ways to show them.

Now, Xiao Piqiu wants the number of his showing strategies to be at least MM. How much money does he need to spend at least?

Input Format

The first line contains two integers N,MN, M.

The second line contains NN integers, representing the number of skins for each champion KiK_i.

The third line contains NN integers, representing the price of each champion’s skins CiC_i.

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 44 skins, and each skin costs 22 Q-coins. Then for each champion, buy 33 skins: 3×3×3243 \times 3 \times 3 \ge 24. The total cost is 6×36 \times 3 Q-coins.

Constraints

There are 1010 test cases in total. For the ii-th test case: Nmax(5,log24i)N \le \max(5, \log_2^4{i}).

For 100%100\% of the testdata: M1017,1Ki10,1Ci199M \le 10^{17}, 1 \le K_i \le 10, 1 \le C_i \le 199. A solution is guaranteed to exist.

Translated by ChatGPT 5