CF46B.T-shirts from Sponsor
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
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恤作为礼物。一个自然的问题随之产生:一方面,尚不清楚究竟应订购多少件、各尺寸(S、M、L、XL、XXL)的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测评打分。不知道怎么写?