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.

Input

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 100 000.

The second line contains positive integer n (1 ≤ n ≤ 100 000) — 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.

Output

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.

Examples
input
0 1 0 1 1 0
3
XL
S,M
XL,XXL
output
YES
XL
M
XXL
input
1 1 2 0 1 1
5
S
M
S,M
XXL,XXXL
XL,XXL
output
NO
题意:那个有6种不同的衣服。有些人尺码确定的,有些人则位于中间,比如XL~XXL,问怎么分配
解法:
1 优先分配单独的
2 两种选择的优先权是"S,M","M,L","L,XL","XL,XXL","XXL,XXXL",(高->低)
3 然后...其实就这样,再改改输出就行
4 当时认为是剩余多的先选WA到死
 #include<bits/stdc++.h>
using namespace std;
map<string,int>Mp,mp;
int a[];
string s[];
string s2[];
string s3[]={" ","S","M","L","XL","XXL","XXXL"};
string ss[]={" ","S,M","M,L","L,XL","XL,XXL","XXL,XXXL"};
vector<string>Ve;
int main(){
mp["S"]=;
mp["M"]=;
mp["L"]=;
mp["XL"]=;
mp["XXL"]=;
mp["XXXL"]=;
Mp["S,M"]=;
Mp["M,L"]=;
Mp["L,XL"]=;
Mp["XL,XXL"]=;
Mp["XXL,XXXL"]=;
for(int i=;i<=;i++){
cin>>a[i];
} //cout<<a[mp["XXL"]]<<endl;
int m;
cin>>m;
for(int i=;i<=m;i++){
cin>>s[i];
if(Mp[s[i]]==){
a[mp[s[i]]]--;
}
}
for(int i=;i<=;i++){
if(a[i]<){
cout<<"NO"<<endl;
return ;
}
}
for(int i=;i<=;i++){
for(int j=;j<=m;j++){
if(ss[i]==s[j]){
if(a[Mp[s[j]]]){
a[Mp[s[j]]]--;
s[j]=s3[Mp[s[j]]];
}else if(a[Mp[s[j]]+]){
a[Mp[s[j]]+]--;
s[j]=s3[Mp[s[j]]+];
}else{
cout<<"NO"<<endl;
return ;
}
}
}
}
cout<<"YES"<<endl;
for(int i=;i<=m;i++){
cout<<s[i]<<endl;
}
return ;
}
 

Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) D的更多相关文章

  1. Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) C

    This is an interactive problem. You should use flush operation after each printed line. For example, ...

  2. Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) B

    Vasily exited from a store and now he wants to recheck the total price of all purchases in his bill. ...

  3. Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) A

    Vasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types ...

  4. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) C

    Description Santa Claus has Robot which lives on the infinite grid and can move along its lines. He ...

  5. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) B

    Description Santa Claus decided to disassemble his keyboard to clean it. After he returned all the k ...

  6. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) A

    Description Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the f ...

  7. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) D. Santa Claus and a Palindrome STL

    D. Santa Claus and a Palindrome time limit per test 2 seconds memory limit per test 256 megabytes in ...

  8. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) E. Santa Claus and Tangerines

    E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  9. Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)

    http://codeforces.com/contest/737 A: 题目大意: 有n辆车,每辆车有一个价钱ci和油箱容量vi.在x轴上,起点为0,终点为s,中途有k个加油站,坐标分别是pi,到每 ...

随机推荐

  1. 基于Appium、Python的自动化测试

    基于Appium.Python的自动化测试环境部署和实践   第一章 导言 1.1 编制目的 该文档为选用Appium作为移动设备原生(Native).混合(Hybrid).移动Web(Mobile ...

  2. Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stoc

    今天在使用yum安装文件时,出现了以下问题: root@localhost opt]# yum update Loaded plugins: fastestmirror Could not retri ...

  3. Java 出现“Illegal key size”错误的解决方案

    用AES加密时出现"java.security.InvalidKeyException: Illegal key size"异常. 如果密钥大于128, 会抛出上述异常.因为密钥长 ...

  4. Chapter 3 Shared Assemblies and Strongly Named Assemblies

    As time marches on,MS developers and control developer modify their code:they fix bugs,patch securit ...

  5. 启动jmeter报错

    启动jmeter.bat时报错

  6. 【linux】lsof命令和{Linux下文件删除、句柄与空间释放问题}

      导读: 一.用事实说话 二.关于LSOF命令的其它用法: 三.参考文档:   正文: lsof:Finding open files with lsof 作用:查看文件被哪些进程打开 一.用事实说 ...

  7. Swift 控制语句

    Control Flow指的是『逻辑控制语句』,包括if.if-else.for.for-in.while.do-while.switch等.其中大部分和OC中差不多,但Swift在某些方便增强了控制 ...

  8. bzoj2730矿场搭建——点双连通分量

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2730 首先一遍tarjan找出割点,将图缩点,这些大点中如果有只包含一个割点的,那么如果这个 ...

  9. MTK HDMI 流程

    一.HDMI初始化 1. kernel-3.18/drivers/misc/mediatek/ext_disp/mtk_extd_mgr.c static int __init mtk_extd_mg ...

  10. python2代码批量转为python3代码

    由于python存在python2和python3两个主要的版本方向,经常会有将python2的代码转到python3的环境下运行的需求.尤其是跑一些神经网络的代码时有很多是在python2的环境下写 ...