Universal Cup Judging System

Universal Cup

Limite de temps : 3.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓
Statistiques

Panda 正在玩一款遊戲,在遊戲中他帶領著一支由 $n$ 個角色(編號從 $1$ 到 $n$)組成的隊伍與惡魔的軍隊戰鬥。每個回合開始時,隊伍都擁有 $m$ 點可用的 Ap(能量值)。

每個角色 $i$ 都擁有一個技能,可以造成 $a_i$ 點傷害,平時消耗 $c_i$ 點 Ap。在任何回合中,每個角色都可以選擇使用一次自己的技能,或者什麼都不做(消耗為零)。在一個回合中使用的所有技能的總 Ap 消耗不得超過 $m$。回合結束時剩餘的任何 Ap 都會被丟棄,且隊伍會在下一回合完全恢復為 $m$ 點 Ap。

由於這款遊戲獨特的機制,如果一個角色在某個回合中使用了技能,那麼在下一回合中,該技能的 Ap 消耗將變為 $c_i + k$。如果該角色在連續的回合中繼續使用該技能,消耗將維持在 $c_i + k$(不會進一步增加)。如果一個角色在某個回合中沒有使用技能,那麼在緊接著的下一回合中,該技能的消耗將重置為 $c_i$。

Panda 想要在總共 $R$ 個回合中最大化造成的總傷害。請找出可能的最大總傷害。

輸入格式

第一行包含一個整數 $T$($1 \le T \le 100$),表示測試資料的組數。

對於每組測試資料,第一行包含四個整數 $n, m, k, R$($1 \le n \le 6$,$1 \le m, k \le 10^3$,$1 \le R \le 10^9$)。其中 $n$ 是隊伍中的角色數量,$m$ 是每個回合開始時獲得的 Ap,$k$ 是使用技能時暫時增加的 Ap 消耗,而 $R$ 是總回合數。

接下來的 $n$ 行,每行包含兩個整數 $a_i, c_i$($1 \le a_i \le 10^6$,$1 \le c_i \le m$),分別代表角色 $i$ 的傷害與初始 Ap 消耗。

輸出格式

請輸出一個整數,代表可以達到的最大總傷害。

範例

輸入格式 1

3
3 7 1 5
59 3
13 2
81 4
5 14 2 9
66 8
20 2
25 4
39 6
57 7
4 13 7 16
18 2
13 5
33 4
7 1

輸出格式 1

490
939
741

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#2660EditorialOpen$O\left(\frac{8^n}{\sqrt n}+n^{3/2}4^n\right)\log R$ by GPT6 ProAnonymousView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.