#P15051. [UOI 2023 II Stage] Nova Poshta

    ID: 16981 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>模拟2023Special Judge枚举深度优先搜索 DFSUOI(乌克兰)

[UOI 2023 II Stage] Nova Poshta

题目描述

In the last minutes of the working day, a rush order for delivery of five oversized cargo items was received at the branch of Nova Poshta. There are only two trucks left in the branch: the first one has a load capacity of M1M_1, and the second one has a load capacity of M2M_2. The driver of the first truck is called Vasyl, and the driver of the second truck is called Petro.

Determine how to distribute the cargo between the trucks to fulfill the order.

输入格式

The first line contains five integers m1m_1, m2m_2, m3m_3, m4m_4, m5m_5 (1m1,m2,m3,m4,m51001 \leq m_1, m_2, m_3, m_4, m_5 \leq 100) --- the weights of the cargo items in tons.

The second line contains two integers M1M_1 and M2M_2 (1M1,M21001 \leq M_1, M_2 \leq 100) --- the load capacities of Vasyl's and Petro's trucks, respectively.

输出格式

If the order cannot be fulfilled, print They can not do it!\texttt{They can not do it!}.

If both Vasyl and Petro can fulfill the order on their own, print They both can do it!\texttt{They both can do it!}.

If the order can be fulfilled by one truck only, but only one of the trucks has sufficient load capacity, print who should do it: Vasyl can do it!\texttt{Vasyl can do it!} or Petro can do it!\texttt{Petro can do it!}.

If the order can be fulfilled but both trucks are needed, print any possible distribution of cargo between the trucks in the following format:

  • Print Theyneedtoworktogether!\tt{They need to work together!} on the first line.
  • On the second line, print the name Vasyl\texttt{Vasyl}, followed by a colon, space, and the numbers of the cargo items that need to be loaded onto the first truck.
  • On the third line, print the name Petro\texttt{Petro}, followed by a colon, space, and the numbers of the cargo items that need to be loaded onto the second truck.

The numbers of the cargo items can be printed in any order.

10 10 10 10 10
20 20
They can not do it!
5 5 5 5 5
25 30
They both can do it!
5 5 5 5 5
30 20
Vasyl can do it!
5 5 5 5 5
10 25
Petro can do it!
7 8 9 10 11
30 30
They need to work together!
Vasyl: 1 2
Petro: 3 4 5
7 8 9 10 11
30 31
They need to work together!
Vasyl: 1 2
Petro: 5 3 4