#P16307. [蓝桥杯 2026 省 Java/Python 研究生组] 抓取卡牌
[蓝桥杯 2026 省 Java/Python 研究生组] 抓取卡牌
Problem Description
There are different types of cards. For the -th type, its base value is , and there are cards of this type.
You need to choose exactly cards from these cards to form your own deck.
For the same type of card, as you choose more of them, the value of later cards will decrease. Specifically, if you have already chosen cards of a type with base value , then the value of the next card of this type is:
means taking the floor of , i.e., the largest integer that does not exceed .
That is:
- When choosing the -st card of this type, its value is ;
- When choosing the -nd card, its value is ;
- When choosing the -rd card, its value is ;
- And so on.
For each type of card, you can choose at most cards.
Now, please compute: when choosing exactly cards, what is the maximum total value you can obtain.
Input Format
The input consists of three lines.
The first line contains two integers , representing the number of card types and the total number of cards that need to be chosen.
The second line contains integers , representing the base value of each card type.
The third line contains integers , representing how many cards are available for each type.
Output Format
Output one line with one integer, representing the maximum total value.
6 6
1 1 2 3 4 5
1 2 1 2 3 4
18
Hint
Sample Explanation
After expanding the values of all possible single cards, we get:
- Type can contribute: .
- Type can contribute: .
- Type can contribute: .
- Type can contribute: .
- Type can contribute: .
- Type can contribute: .
Choose the largest values among them: . Their sum is , so the answer is .
Constraints and Notes for Test Cases
For of the test cases, .
For all test cases, it holds that , , and .
It is guaranteed that the total number of cards is at least .
Translated by ChatGPT 5