Universal Cup Judging System

Universal Cup

Süre Sınırı: 3.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

Panda はゲームをプレイしており、$1$ から $n$ までの番号が付けられた $n$ 人のキャラクターからなるパーティを率いて魔王の軍勢と戦っています。各ラウンドの開始時、パーティには利用可能な $m$ Ap(エネルギーポイント)が与えられます。

各キャラクター $i$ は、$a_i$ のダメージを与え、通常 $c_i$ Ap を消費するスキルを持っています。どのラウンドにおいても、各キャラクターは自分のスキルを 1 回使用するか、コスト 0 で何もしないかのいずれかを選択できます。1 回のラウンドで使用されるすべてのスキルの合計 Ap コストは $m$ を超えてはなりません。ラウンド終了時に残った Ap はすべて破棄され、次のラウンドに向けてパーティの Ap は $m$ に完全回復します。

このゲーム特有の仕組みにより、あるキャラクターがあるラウンドでスキルを使用すると、次のラウンドにおけるそのスキルの Ap コストは $c_i + k$ になります。そのキャラクターが連続するラウンドでスキルを使用し続ける場合、コストは $c_i + k$ のまま維持されます(それ以上増加することはありません)。あるラウンドでキャラクターがスキルを使用しなかった場合、すぐ次のラウンドではそのスキルのコストは $c_i$ にリセットされます。

Panda は全 $R$ ラウンドにわたって与える合計ダメージを最大化したいと考えています。達成可能な合計ダメージの最大値を求めてください。

入力

1 行目にはテストケースの個数を表す単一の整数 $T$($1 \le T \le 100$)が与えられます。

各テストケースについて、1 行目には 4 つの整数 $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$ 行にはそれぞれ、キャラクター $i$ のダメージと初期 Ap コストを表す 2 つの整数 $a_i, c_i$($1 \le a_i \le 10^6$、$1 \le c_i \le m$)が与えられます。

出力

達成可能な合計ダメージの最大値を表す単一の整数を出力してください。

入出力例

入力 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.