303765: CF727D. T-shirts Distribution
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
T-shirts Distribution
题意翻译
编程竞赛的组织者决定向参与者赠送 T 恤。本题有六种不同的 T 恤尺码:S、M、L、XL、XXL、XXXL(尺码按升序排列)。 T恤已经准备好了。对于从 S 到 XXXL 的每个尺码,您都会获得该尺码的 T 恤的数量。 在注册过程中,组织者向每一位参与者询问了他想要的T恤尺寸。如果参与者在两个尺寸之间犹豫不决,他可以指定两个相邻的尺寸——这意味着这两个尺寸中的任何一个都适合他。 编写一个程序,确定是否可以向比赛的每个参与者展示一件 T 恤。当然,每个参与者都应该得到一件合适尺寸的 T 恤: 如果他指定一种尺寸,他想要的尺寸; 两个相邻尺寸中的任何一个,如果他指定了两个尺寸。 如果可能,程序应该找到任何有效的 T 恤分布。 输入的第一行包含六个非负整数——每种尺寸的 T 恤的数量。数字分别针对尺寸 S、M、L、XL、XXL、XXXL。 T 恤的总数不超过 $100000100000$ 。 第二行包含正整数 $nn ( 1<=n<=1000001<=n<=100000 )$ — 参与者的数量。 以下 $nn$ 行包含参与者指定的大小,每个参与者一行。第 $ii$ 行包含第 $ii$ 参与者提供的信息:单个尺寸或用逗号分隔的两个尺寸(没有任何空格)。如果有两种尺寸,则尺寸按升序写入。保证用逗号分隔的两个尺寸是相邻的。 如果不可能向每位参与者展示一件 T 恤,请输出NO。 否则,输出 $n+1n+1$ 行。在第一行输出YES。在接下来的 $nn$ 行中,输出组织者应该给参与者的 T 恤尺寸,每行一件。参与者的顺序应与输入中的顺序相同。 如果有多个解决方案,请输出其中任何一个。题目描述
The organizers of a programming contest have decided to present t-shirts to participants. There are six different t-shirts sizes in this problem: S, M, L, XL, XXL, XXXL (sizes are listed in increasing order). The t-shirts are already prepared. For each size from S to XXXL you are given the number of t-shirts of this size. During the registration, the organizers asked each of the $ n $ participants about the t-shirt size he wants. If a participant hesitated between two sizes, he could specify two neighboring sizes — this means that any of these two sizes suits him. Write a program that will determine whether it is possible to present a t-shirt to each participant of the competition, or not. Of course, each participant should get a t-shirt of proper size: - the size he wanted, if he specified one size; - any of the two neibouring sizes, if he specified two sizes. If it is possible, the program should find any valid distribution of the t-shirts.输入输出格式
输入格式
The first line of the input contains six non-negative integers — the number of t-shirts of each size. The numbers are given for the sizes S, M, L, XL, XXL, XXXL, respectively. The total number of t-shirts doesn't exceed $ 100000 $ . The second line contains positive integer $ n $ ( $ 1<=n<=100000 $ ) — the number of participants. The following $ n $ lines contain the sizes specified by the participants, one line per participant. The $ i $ -th line contains information provided by the $ i $ -th participant: single size or two sizes separated by comma (without any spaces). If there are two sizes, the sizes are written in increasing order. It is guaranteed that two sizes separated by comma are neighboring.
输出格式
If it is not possible to present a t-shirt to each participant, print «NO» (without quotes). Otherwise, print $ n+1 $ lines. In the first line print «YES» (without quotes). In the following $ n $ lines print the t-shirt sizes the orginizers should give to participants, one per line. The order of the participants should be the same as in the input. If there are multiple solutions, print any of them.
输入输出样例
输入样例 #1
0 1 0 1 1 0
3
XL
S,M
XL,XXL
输出样例 #1
YES
XL
M
XXL
输入样例 #2
1 1 2 0 1 1
5
S
M
S,M
XXL,XXXL
XL,XXL
输出样例 #2
NO