CF1776D.Teamwork

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

As soon as SWERC starts, your experienced 33-person team immediately realizes that the contest features aa easy problems, bb medium problems, and cc hard problems. Solving a problem will take any of you 22, 33, or 44 time units, depending on whether the problem is easy, medium, or hard. Regardless of the difficulty of the problem, the last time unit spent to solve it has to be spent using your shared computer.

You organize your efforts so that each of you starts (and ends) solving problems at integer time units. Any given problem can be solved by only one contestant; it requires a contiguous amount of time (which depends on the difficulty of the problem). None of the 33 of you can solve more than one problem at a time, but you can start solving a new problem immediately after finishing one. Similarly, the shared computer cannot be used by more than one of you at a time, but any of you can start using the computer (to complete the problem currently being solved) immediately after someone else stops using it.

Given that the contest lasts ll time units, find the maximum number of problems that your team can solve. Additionally, find one way to solve the maximum number of problems.

SWERC 开始后,你们这支经验丰富的三人队伍立即发现本次比赛共有 aa 道简单题、bb 道中等题和 cc 道难题。解决一道题目所需时间为 22、33 或 44 个时间单位,分别对应题目难度为简单、中等或困难。无论题目难度如何,解决该题的最后一个时间单位必须使用你们共用的计算机。

你们协调分工,使得每位队员均在整数时刻开始(并结束)解题。任意一道题目只能由一名队员独立完成,且需连续占用相应时长(取决于题目难度)。三人中任意一人同一时刻最多只能解一道题,但可在刚完成一道题后立即开始下一道题。类似地,共用计算机同一时刻最多只能被一人使用,但当某位队员刚释放计算机后,其他任意队员可立即使用它(以完成当前正在解的题目)。

已知比赛总时长为 ll 个时间单位,求你们队伍最多能解决多少道题目;并给出一种达成该最大题数的具体方案。

输入格式

The input has a single line. It contains four integers aa, bb, cc, ll (0≤a,b,c,≤1040 \leq a, b, c, \leq 10^4, 0≤l≤1050 \le l \le 10^5) — the number of easy, medium, and hard problems, and the duration of the contest.

输入仅有一行。包含四个整数 aa、bb、cc、ll(0≤a,b,c≤1040 \leq a, b, c \leq 10^4,0≤l≤1050 \le l \le 10^5)——分别表示简单题、中等题和难题的数量,以及比赛的持续时间。

输出格式

On the first line, print a single integer nn — the maximum number of problems that your team can solve.

Then, on the jj-th of the following nn lines, print three integers xjx_j, pjp_j, qjq_j (1≤x≤31 \leq x \leq 3, 0≤pj<qj≤l0 \leq p_j \lt q_j \leq l) — the contestant that solves the jj-th problem, and the start and end time for solving the jj-th problem (measured as time units elapsed from the beginning of the contest). The difference qj−pjq_j - p_j is 22, 33, or 44, depending on the difficulty of the problem.

The last nn lines are to be provided in increasing order of end time: q1<q2<⋯<qnq_1 \lt q_2 \lt \cdots \lt q_n. If there are multiple ways to solve nn problems, output any of them.

第一行输出一个整数 nn —— 你的队伍最多能解决的问题数量。

接下来的 nn 行中,第 jj 行输出三个整数 xjx_j、pjp_j、qjq_j(其中 1≤x≤31 \leq x \leq 3,0≤pj<qj≤l0 \leq p_j \lt q_j \leq l)—— 分别表示解决第 jj 个问题的参赛队员,以及解决该问题的起始时间和结束时间(以比赛开始后经过的时间单位计量)。差值 qj−pjq_j - p_j 为 22、33 或 44,具体取决于该问题的难度。

最后这 nn 行需按结束时间递增顺序给出:即满足 q1<q2<⋯<qnq_1 \lt q_2 \lt \cdots \lt q_n。若存在多种解决 nn 个问题的方式,输出任意一种即可。

输入输出样例

  • 输入#1

    2 1 1 3

    输出#1

    2
    1 0 2
    2 0 3
  • 输入#2

    1 2 3 5

    输出#2

    4
    1 0 2
    2 0 3
    3 0 4
    1 2 5
  • 输入#3

    0 1 2 2

    输出#3

    0

说明/提示

In the first sample, the first contestant solves an easy problem between time 00 and time 22 while the second contestant solves a medium problem between time 00 and time 33.

In the second sample, the first contestant solves an easy problem between time 00 and time 22, and then also solves a medium problem between time 22 and time 55. In the meantime, the second contestant solves another medium problem between time 00 and time 33, while the third contestant solves a hard problem between time 00 and time 44.

In the third sample, the contest only has medium and hard problems, and there is not enough time to solve any of them.

在第一个样例中,第一位参赛者在时间 00 到 22 之间解决了一道简单题,而第二位参赛者在时间 00 到 33 之间解决了一道中等题。

在第二个样例中,第一位参赛者在时间 00 到 22 之间解决了一道简单题,随后又在时间 22 到 55 之间解决了一道中等题。与此同时,第二位参赛者在时间 00 到 33 之间解决了另一道中等题,而第三位参赛者在时间 00 到 44 之间解决了一道难题。

在第三个样例中,比赛仅包含中等题和难题,且时间不足以解决其中任意一道。

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

首页