CF1260D.A Game with Traps

普及+/提高

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are playing a computer game, where you lead a party of mm soldiers. Each soldier is characterised by his agility aia_i.

The level you are trying to get through can be represented as a straight line segment from point 00 (where you and your squad is initially located) to point n+1n + 1 (where the boss is located).

The level is filled with kk traps. Each trap is represented by three numbers lil_i, rir_i and did_i. lil_i is the location of the trap, and did_i is the danger level of the trap: whenever a soldier with agility lower than did_i steps on a trap (that is, moves to the point lil_i), he gets instantly killed. Fortunately, you can disarm traps: if you move to the point rir_i, you disarm this trap, and it no longer poses any danger to your soldiers. Traps don't affect you, only your soldiers.

You have tt seconds to complete the level — that is, to bring some soldiers from your squad to the boss. Before the level starts, you choose which soldiers will be coming with you, and which soldiers won't be. After that, you have to bring all of the chosen soldiers to the boss. To do so, you may perform the following actions:

  • if your location is xx, you may move to x+1x + 1 or x−1x - 1. This action consumes one second;
  • if your location is xx and the location of your squad is xx, you may move to x+1x + 1 or to x−1x - 1 with your squad in one second. You may not perform this action if it puts some soldier in danger (i. e. the point your squad is moving into contains a non-disarmed trap with did_i greater than agility of some soldier from the squad). This action consumes one second;
  • if your location is xx and there is a trap ii with ri=xr_i = x, you may disarm this trap. This action is done instantly (it consumes no time).

Note that after each action both your coordinate and the coordinate of your squad should be integers.

You have to choose the maximum number of soldiers such that they all can be brought from the point 00 to the point n+1n + 1 (where the boss waits) in no more than tt seconds.

你正在玩一款电脑游戏,游戏中你率领一支由 mm 名士兵组成的队伍。每名士兵有一个敏捷值 aia_i。

你当前试图通过的关卡可以表示为一条从点 00(你和你的队伍初始所在位置)到点 n+1n + 1(Boss 所在位置)的直线线段。

该关卡中布置了 kk 个陷阱。每个陷阱由三个整数 lil_i、rir_i 和 did_i 描述:lil_i 是陷阱的位置,did_i 是该陷阱的危险等级;当一名敏捷值小于 did_i 的士兵踩上该陷阱(即移动至点 lil_i)时,他会立即死亡。幸运的是,你可以解除陷阱:若你移动至点 rir_i,则该陷阱即被解除,此后不再对你的士兵构成任何威胁。注意:陷阱仅影响你的士兵,对你本人无影响。

你必须在 tt 秒内完成该关卡——即把若干名士兵从起点成功带至 Boss 所在位置。关卡开始前,你需要决定哪些士兵随你同行、哪些士兵留守。之后,你必须将所有选定的士兵全部带至 Boss 所在点 n+1n + 1。为此,你可以执行以下操作:

  • 若你当前位于位置 xx,你可以移动至 x+1x + 1 或 x−1x - 1,每次移动耗时 1 秒;
  • 若你当前位于位置 xx,且你的队伍也位于位置 xx,则你可以带领整个队伍一起移动至 x+1x + 1 或 x−1x - 1,耗时 1 秒;但该操作不可使任何士兵陷入危险(即:队伍即将移入的位置若存在尚未解除的陷阱 ii,且其危险等级 did_i 大于队伍中某名士兵的敏捷值 aja_j,则该操作禁止执行);
  • 若你当前位于位置 xx,且存在某个陷阱 ii 满足 ri=xr_i = x,则你可以立即解除该陷阱(不消耗时间)。

注意:每次操作后,你和你的队伍所处的位置坐标均为整数。

你需要选择尽可能多的士兵,使得他们全部能从点 00 被安全带至点 n+1n + 1(Boss 所在处),且总耗时不超过 tt 秒。

输入格式

The first line contains four integers mm, nn, kk and tt (1≤m,n,k,t≤2⋅1051 \le m, n, k, t \le 2 \cdot 10^5, n<tn \lt t) — the number of soldiers, the number of integer points between the squad and the boss, the number of traps and the maximum number of seconds you may spend to bring the squad to the boss, respectively.

The second line contains mm integers a1a_1, a2a_2, ..., ama_m (1≤ai≤2⋅1051 \le a_i \le 2 \cdot 10^5), where aia_i is the agility of the ii-th soldier.

Then kk lines follow, containing the descriptions of traps. Each line contains three numbers lil_i, rir_i and did_i (1≤li≤ri≤n1 \le l_i \le r_i \le n, 1≤di≤2⋅1051 \le d_i \le 2 \cdot 10^5) — the location of the trap, the location where the trap can be disarmed, and its danger level, respectively.

第一行包含四个整数 mm、nn、kk 和 tt(1≤m,n,k,t≤2⋅1051 \le m, n, k, t \le 2 \cdot 10^5,且 n<tn \lt t),分别表示士兵人数、小队与 Boss 之间的整数坐标点数量、陷阱数量以及将小队带至 Boss 处所允许的最长时间(单位:秒)。

第二行包含 mm 个整数 a1a_1、a2a_2、...、ama_m(1≤ai≤2⋅1051 \le a_i \le 2 \cdot 10^5),其中 aia_i 表示第 ii 名士兵的敏捷值。

接下来是 kk 行,每行描述一个陷阱。每行包含三个数 lil_i、rir_i 和 did_i(1≤li≤ri≤n1 \le l_i \le r_i \le n,1≤di≤2⋅1051 \le d_i \le 2 \cdot 10^5),分别表示该陷阱的位置、可解除该陷阱的位置,以及其危险等级。

输出格式

Print one integer — the maximum number of soldiers you may choose so that you may bring them all to the boss in no more than tt seconds.

输出一个整数——在不超过 tt 秒的时间内,你能带到 Boss 处的士兵的最大数量。

输入输出样例

  • 输入#1

    5 6 4 14
    1 2 3 4 5
    1 5 2
    1 2 5
    2 3 5
    3 5 3

    输出#1

    3

说明/提示

In the first example you may take soldiers with agility 33, 44 and 55 with you. The course of action is as follows:

  • go to 22 without your squad;
  • disarm the trap 22;
  • go to 33 without your squad;
  • disartm the trap 33;
  • go to 00 without your squad;
  • go to 77 with your squad.

The whole plan can be executed in 1313 seconds.

在第一个例子中,你可以带上敏捷值为 33、44 和 55 的士兵。具体行动步骤如下:

  • 不带小队前往位置 22;
  • 解除陷阱 22;
  • 不带小队前往位置 33;
  • 解除陷阱 33;
  • 不带小队前往位置 00;
  • 带上小队前往位置 77。

整个计划可在 1313 秒内完成。

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

首页