CF46B.T-shirts from Sponsor
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
One day a well-known sponsor of a well-known contest decided to give every participant of the contest a T-shirt as a present. A natural problem occurred: on the one hand, it is not clear how many T-shirts of what sizes should be ordered, and on the other hand, one doesn't want to order too many T-shirts (and we do not exactly paper the walls with the oversupply). After considerable brain racking and some pre-estimating, the sponsor representatives ordered a certain number of T-shirts of sizes S, M, L, XL and XXL. The T-shirts turned out to bring good luck, that's why on the contest day there built up a line of K participants willing to get one. Every contestant is characterized by his/her desired T-shirt size (so it happens that for all the participants it is also one of the sizes S, M, L, XL and XXL). The participants come up to get a T-shirt one by one and try to choose the most suitable one, choosing it like this. If there is still a T-shirt of the optimal size left, that he/she takes it without further ado. Otherwise the contestant would prefer to choose a T-shirt with the size as close to the optimal one as possible (the distance between neighboring sizes is considered equal to one). If the variant of choice is not unique, the contestant will take a T-shirt of a bigger size (in case he/she grows more). For example, for a person whose optimal size is L the preference list looks like this: L, XL, M, XXL, S. Using the data on how many T-shirts of every size had been ordered by the organizers, on the size of contestants in the line determine who got a T-shirt of what size.
某天,一场知名竞赛的知名赞助商决定为每位参赛者赠送一件T恤作为礼物。一个自然的问题随之出现:一方面,尚不清楚应订购多少件、各尺码分别为多少的T恤;另一方面,又不希望订购过多T恤(我们当然不会用过剩的T恤去糊墙)。经过大量脑力激荡和若干初步估算后,赞助方代表订购了若干件尺码为 S、M、L、XL 和 XXL 的T恤。这些T恤似乎带来了好运,因此在比赛当天,排起了由 K 名参与者组成的长队,人人都想领一件。每位参赛者均有一个其偏好的T恤尺码(恰好也属于 S、M、L、XL、XXL 这五种尺码之一)。参与者依次上前领取T恤,并按如下规则选择最合适的尺码:若其理想尺码仍有库存,则直接取走该尺码的T恤;否则,参赛者将优先选择与理想尺码距离最近的有库存尺码(相邻尺码间的距离定义为 1);若存在多个等距可选尺码,则选择其中尺码更大的那个(以防日后长高)。例如,对理想尺码为 L 的人而言,其偏好顺序为:L、XL、M、XXL、S。
请根据主办方订购的各尺码T恤数量以及排队参赛者的理想尺码,确定每位参赛者最终领取到的T恤尺码。
输入格式
The first line contains five non-negative integers N__S, N__M, N__L, N__XL, N__XXL not exceeding 1000 which represent the number of T-shirts of the corresponding sizes. The second line contains an integer K (1 ≤ K ≤ 1000) which represents the number of participants. The next K lines contain the optimal T-shirt sizes for the contestants. The sizes are given in the order in which the participants stand in the line. It is guaranteed that N__S + N__M + N__L + N__XL + N__XXL ≥ K.
第一行包含五个不超过 1000 的非负整数 NS,NM,NL,NXL,NXXL,分别表示对应尺码的 T 恤数量。
第二行包含一个整数 K(1≤K≤1000),表示参赛者人数。
接下来的 K 行每行给出一名参赛者最合适的 T 恤尺码,顺序与参赛者在队列中的站位顺序一致。
保证 NS+NM+NL+NXL+NXXL≥K。
输出格式
For each contestant, print a line containing the size of the T-shirt he/she got.
对于每位参赛者,输出一行,包含他/她获得的 T 恤尺码。
输入输出样例
输入#1
1 0 2 0 1 3 XL XXL M
输出#1
XXL L L
输入解题思路,AI测评打分。不知道怎么写?