CF1832F.Zombies

NOI/NOI+/CTSC

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Polycarp plays a computer game in a post-apocalyptic setting. The zombies have taken over the world, and Polycarp with a small team of survivors is defending against hordes trying to invade their base. The zombies are invading for xx minutes starting from minute 00. There are nn entrances to the base, and every minute one zombie attempts to enter through every entrance.

The survivors can defend the entrances against the zombies. There are two options:

  • manually — shoot the zombies coming through a certain entrance;
  • automatically — set up an electric fence on a certain entrance to fry the zombies.

If an entrance is defended either or both ways during some minute, no zombie goes through.

Every entrance is defended by a single dedicated survivor. The ii-th entrance is defended manually from minute lil_i until minute rir_i, non-inclusive — [li,ri)[l_i, r_i).

There are kk generators that can be used to defend the entrances automatically. Every entrance should be connected to exactly one generator, but a generator can be connected to multiple entrances (or even none of them). Each generator will work for exactly mm consecutive minutes. Polycarp can choose when to power on each generator independently of each other, the mm minute long interval should be fully inside the [0,x)[0, x) time interval.

Polycarp is a weird gamer. He wants the game to be as difficult as possible for him. So he wants to connect each entrance to a generator and choose the time for each generator in such a way that as many zombies as possible enter the base. Please, help him to achieve that!

波利卡普正在玩一款末日废土题材的电脑游戏。僵尸已经占领了世界,波利卡普与一小队幸存者正共同抵御一波波企图入侵他们基地的僵尸潮。僵尸将从第 00 分钟开始持续入侵 xx 分钟。基地共有 nn 个入口,且每分钟每个入口都恰好有一只僵尸试图闯入。

幸存者可以对入口进行防御,防御方式有两种:

  • 手动防御:向某一入口涌来的僵尸开枪射击;
  • 自动防御:在某一入口架设电篱笆以电击僵尸。

若某入口在某分钟内被任一(或两种)方式成功防御,则该分钟内不会有僵尸通过。

每个入口均由一名专属幸存者负责手动防御。第 ii 个入口的手动防御时间区间为第 lil_i 分钟至第 rir_i 分钟(不含右端点),即半开区间 [li,ri)[l_i, r_i)。

此外,基地还有 kk 台发电机可用于实现自动防御。每台发电机可连接至任意数量(包括零台)的入口,但每个入口必须且只能连接至一台发电机。每台发电机一旦启动,将连续工作恰好 mm 分钟。波利卡普可独立决定每台发电机的启动时刻,但其工作的 mm 分钟区间必须完全落在总时间区间 [0,x)[0, x) 内。

波利卡普是一位特立独行的玩家,他希望游戏对他而言尽可能困难。因此,他希望在为每个入口分配发电机、并为每台发电机选定启动时刻时,使得最终成功进入基地的僵尸总数最大化。请帮助他实现这一目标!

输入格式

The first line contains four integers n,k,xn, k, x and mm (1≤k≤n≤20001 \le k \le n \le 2000; 1≤m≤x≤1091 \le m \le x \le 10^9) — the number of entrances, the number of generators, the duration of the zombie invasion and the duration of all generators.

The ii-th of the next nn lines contains two integers lil_i and rir_i (0≤li<ri≤x0 \le l_i \lt r_i \le x) — the time interval the ii-th entrance is defended manually.

第一行包含四个整数 n,k,xn, k, x 和 mm(1≤k≤n≤20001 \le k \le n \le 2000;1≤m≤x≤1091 \le m \le x \le 10^9)—— 分别表示入口数量、发电机数量、僵尸入侵持续时间以及所有发电机的总持续时间。

接下来的 nn 行中,第 ii 行包含两个整数 lil_i 和 rir_i(0≤li<ri≤x0 \le l_i \lt r_i \le x)—— 表示第 ii 个入口由人工防守的时间区间。

输出格式

Print a single integer — the largest number of zombies that can enter the base after Polycarp connects each entrance to some generator and chooses the time for each generator.

输出一个整数——即在波利卡普将每个入口连接至某个发电机并为每个发电机选择启动时间后,能够进入基地的僵尸的最大数量。

输入输出样例

  • 输入#1

    3 3 10 3
    0 2
    1 7
    4 7

    输出#1

    18
  • 输入#2

    3 2 10 3
    0 2
    1 7
    4 7

    输出#2

    18
  • 输入#3

    3 1 10 3
    0 2
    1 7
    4 7

    输出#3

    16
  • 输入#4

    2 1 20 6
    11 13
    2 14

    输出#4

    22
  • 输入#5

    5 3 7 4
    4 6
    0 3
    4 7
    1 5
    2 7

    输出#5

    14
  • 输入#6

    6 3 9 4
    3 9
    4 9
    2 5
    0 5
    6 9
    2 3

    输出#6

    26

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

首页