#P16579. [GKS 2016 #A] Clash Royale
[GKS 2016 #A] Clash Royale
题目描述
Clash Royale is a real time strategy card game. Each card has an attack power and a level. Each player picks 8 cards to form a battle deck; the total attack power of a deck is the sum of the attack power of each of its cards. Players fight with each other by placing cards from their battle decks into the battle arena. The winner of a battle is rewarded with coins, which can be used to upgrade cards. Upgrading a card increases its attack power.
After days of arena fighting, Little Shawn has accumulated a total of coins. He has decided to upgrade some of his cards. Little Shawn has cards. The -th card can have any level from 1 through ; the attack power for the -th level is . Cards must be upgraded one level at a time; the price to upgrade the -th card from level to level costs coins. The -th card is currently at level before Little Shawn has upgraded any cards.
Little Shawn wants to use some or all of his coins to upgrade cards, and then form a deck of exactly 8 cards, so that the deck's total attack power is as large as possible. Can you help him do this? He can upgrade the same card more than once as long as he can afford it, and he does not have to upgrade every card.
输入格式
The first line of the input gives the number of test cases, . test cases follow. Each test case starts with 2 integers and , the number of coins and the number of cards that Little Shawn possesses. Then blocks follow. The -th block consists of 3 lines describing the -th card. The first line contains two integers and , the maximum possible level and current level of the card. The second line contains integers , the attack power of each level. The third line contains integers , the number of coins required to upgrade a card that is currently at level 1, 2, ..., .
输出格式
For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is the maximal possible total attack power of a deck that Little Shawn can form, using the coins that he has.
2
20 8
3 1
1 10 100
1 2
3 1
1 10 100
1 3
3 1
1 10 100
1 4
3 1
1 10 100
1 5
3 1
1 10 100
1 6
3 1
1 10 100
1 7
3 1
1 10 100
1 8
3 1
1 10 100
1 9
30 10
4 1
1 10 100 200
1 2 3
3 1
1 10 100
2 4
3 1
1 10 100
3 6
4 2
1 10 100 200
4 8 16
3 1
1 10 100
5 10
3 1
1 10 100
6 12
3 1
1 10 100
7 14
3 1
1 10 100
8 16
3 1
1 10 100
9 18
3 1
1 10 100
10 20
Case #1: 422
Case #2: 504
提示
In sample case #, you can upgrade the first cards to level , upgrade the 5th and 6th card to level , keep the last cards level . This will cost you coins and the total attack power is which is the maximal possible we can get.
Sample case # will only appear in large dataset.
Limits
.
.
.
.
Small dataset (Test set 1 - Visible)
.
.
.
.
Large dataset (Test set 2 - Hidden)
.
.
.
.