No.3634 Made to order
タグ : / 解いたユーザー数 24
作問者 : 👑
Problem Statement
Bartok Construction manufactures made-to-order desks.
One day, the company received the following request.
Please deliver $N$ desks within $D$ days.
According to the foreman, manufacturing $1$ desk requires performing process $1$ → process $2$ → process $3$ in this order.
Manufacturing desk $i$ takes $A_i, B_i, C_i$ days for process $1$, process $2$, and process $3$, respectively.
The company has $1$ dedicated machine for each process, and each machine can handle only $1$ work-in-progress item (= a desk in the middle of being manufactured) at a time.
Work-in-progress items are placed on the line as soon as it is decided to manufacture them, so an item that has completed a process undergoes the next process as soon as the machine for that process becomes free.
Therefore, the desks may be manufactured in any order, but work cannot be interrupted until all processes are finished.
Also, the order of input cannot be changed between processes. For example, an item that started process $1$ earlier must also start process $2$ earlier.
When the manufacturing order is chosen optimally so that delivery happens as early as possible, determine whether all the desks can be completed within $D$ days from the start of work.
Note that delivery cannot take place until all items are completed, and it takes place immediately on the day all items are completed.
Constraints
- $1 \leq N \leq 13$
- $1 \leq D \leq 5 \times 10^3$
- $1 \leq A_i, B_i, C_i \leq 100$ ($1 \leq i \leq N$)
- All input values are integers.
Input
$N\ D$ $A_1\ B_1\ C_1$ $A_2\ B_2\ C_2$ $\vdots$ $A_N\ B_N\ C_N$
Output
Print Yes if a manufacturing order satisfying the condition exists, and No otherwise, on $1$ line.
Print a newline at the end.
Partial Score
This problem has partial scoring based on subtasks.
| Subtask | Score | Constraints |
|---|---|---|
| サブタスク $1$ | 20% (60 pts) | $(A, B, C)$ について,$min(A_i) ≥ max(B_i)$ または $min(C_i) ≥ max(B_i)$ を満たす,$N ≤ 13$ までの入力 |
| サブタスク $2$ | 10% (30 pts) | サブタスク $1$ の条件を満たすとは限らない,$N ≤ 10$ までの入力 |
| サブタスク $3$ | 70% (210 pts) | サブタスク $1$ の条件を満たすとは限らない,$N ≤ 13$ までの入力 |
That is, you must get AC on sample $1$ for subtask $1$, sample $2$ for subtask $2$, and sample $3$ for subtask $3$.
Also, if you write code that can get AC only on subtask $2$, it may get TLE on the code test of subtask $1$.
Therefore, when submitting such code, it is recommended to make it terminate immediately if the constraints of subtask $2$ are not satisfied.
Sample
Sample 1
Input
3 18 5 4 2 6 2 1 4 4 4
Output
Yes
For example, by making the desks in the order desk $3$ → desk $1$ → desk $2$, it is possible to meet the deadline $D$ of $18$ days. The manufacturing process in this case is shown in the figure below.
Sample 2
Input
6 422 75 100 15 74 75 20 80 57 53 48 42 1 5 68 1 78 55 94
Output
No
Sample 3
Input
11 724 73 98 9 33 16 64 98 58 61 84 49 27 13 63 4 50 56 78 98 99 1 90 58 35 93 30 76 14 41 4 3 4 84
Output
No
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。