CF1176F.Destroy it!

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game.

The boss battle consists of nn turns. During each turn, you will get several cards. Each card has two parameters: its cost cic_i and damage did_i. You may play some of your cards during each turn in some sequence (you choose the cards and the exact order they are played), as long as the total cost of the cards you play during the turn does not exceed 33. After playing some (possibly zero) cards, you end your turn, and all cards you didn't play are discarded. Note that you can use each card at most once.

Your character has also found an artifact that boosts the damage of some of your actions: every 1010-th card you play deals double damage.

What is the maximum possible damage you can deal during nn turns?

你正在玩一款名为《劈开邪神》的电脑卡牌游戏。目前,你正努力击败游戏的最终 Boss。

Boss 战共持续 nn 回合。在每一回合中,你会获得若干张卡牌。每张卡牌有两个参数:费用 cic_i 和伤害值 did_i。在每一回合中,你可以按任意顺序(由你选择所使用的卡牌及其出牌顺序)打出若干张手牌,但该回合内所有打出卡牌的总费用不能超过 33。打出若干张(可能为零张)卡牌后,你结束当前回合,所有未打出的卡牌将被弃掉。注意:每张卡牌至多只能使用一次。

此外,你的角色获得了一件神器,可增强部分行动的伤害:你打出的第 1010、2020、3030、…\dots 张卡牌(即每第 1010 张卡牌)造成的伤害翻倍。

在 nn 回合内,你能造成的最大总伤害是多少?

输入格式

The first line contains one integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) — the number of turns.

Then nn blocks of input follow, the ii-th block representing the cards you get during the ii-th turn.

Each block begins with a line containing one integer kik_i (1≤ki≤2⋅1051 \le k_i \le 2 \cdot 10^5) — the number of cards you get during ii-th turn. Then kik_i lines follow, each containing two integers cjc_j and djd_j (1≤cj≤31 \le c_j \le 3, 1≤dj≤1091 \le d_j \le 10^9) — the parameters of the corresponding card.

It is guaranteed that ∑i=1nki≤2⋅105\sum \limits_{i = 1}^{n} k_i \le 2 \cdot 10^5.

第一行包含一个整数 nn(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5)—— 表示回合数。

随后是 nn 个输入块,其中第 ii 个块表示你在第 ii 回合获得的卡片。

每个块以一行开始,该行包含一个整数 kik_i(1≤ki≤2⋅1051 \le k_i \le 2 \cdot 10^5)—— 表示你在第 ii 回合获得的卡片数量。接下来是 kik_i 行,每行包含两个整数 cjc_j 和 djd_j(1≤cj≤31 \le c_j \le 3,1≤dj≤1091 \le d_j \le 10^9)—— 分别表示对应卡片的参数。

保证 ∑i=1nki≤2⋅105\sum \limits_{i = 1}^{n} k_i \le 2 \cdot 10^5。

输出格式

Print one integer — the maximum damage you may deal.

输出一个整数——你能造成的最大伤害值。

输入输出样例

  • 输入#1

    5
    3
    1 6
    1 7
    1 5
    2
    1 4
    1 3
    3
    1 10
    3 5
    2 3
    3
    1 15
    2 4
    1 10
    1
    1 100

    输出#1

    263

说明/提示

In the example test the best course of action is as follows:

During the first turn, play all three cards in any order and deal 1818 damage.

During the second turn, play both cards and deal 77 damage.

During the third turn, play the first and the third card and deal 1313 damage.

During the fourth turn, play the first and the third card and deal 2525 damage.

During the fifth turn, play the only card, which will deal double damage (200200).

在样例测试中,最优策略如下:

第一回合:以任意顺序打出全部三张卡牌,造成 1818 点伤害。

第二回合:打出两张卡牌,造成 77 点伤害。

第三回合:打出第一张和第三张卡牌,造成 1313 点伤害。

第四回合:打出第一张和第三张卡牌,造成 2525 点伤害。

第五回合:打出唯一剩余的卡牌,该卡牌将造成双倍伤害(200200 点)。

输入解题思路,AI测评打分。不知道怎么写?

首页