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. Android Weekly Notes Issue #241

    Android Weekly Issue #241 January 22nd, 2017 Android Weekly Issue #241 本期内容包括: 经典导航模式Master/Detail的设 ...

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

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

  3. 在ubuntu16.04上编译android源码【转】

    本文转载自:http://blog.csdn.net/fuchaosz/article/details/51487585 1 前言 经过3天奋战,终于在Ubuntu 16.04上把Android 6. ...

  4. sdutoj 2373 Black and white painting( 规律统计计算 3Y )

    Black and white painting 题目描述 You are visiting the Centre Pompidou which contains a lot of modern pa ...

  5. 利用javascript动态创建表格

    //说明:实现功能.原理上文相同.不过这次是利用已有的简单的方法创建行和列,并实现内容行鼠标移入变色功能! 效果图: /*两个方法 1.  trNode  table.insertRow(-1)    ...

  6. MYSQL进阶学习笔记十七:MySQL定期维护!(视频序号:进阶_36)

    知识点十八:MySQL定期维护(37) 一.Mysql的定时器 所谓的定时器,指的是在某个时间段去执行同样的代码.比如闹钟.每到指定的时间闹铃就会响.同样的,我们这个定时器,只要满足我们的一个定时条件 ...

  7. 纯属娱乐,对入门Android有一定的帮助

    package android.m9;   import android.app.Activity; import android.os.Bundle; import android.view.Men ...

  8. excel 基本用法

  9. Azure Key Vault (1) 入门

    <Windows Azure Platform 系列文章目录> 为什么要使用Azure Key Vault? 我们假设在微软云Azure上有1个场景,在Windows VM里面有1个.NE ...

  10. 三、Chrome开发者工具详解(3)-Timeline面板

    摘自: http://www.cnblogs.com/charliechu/p/5992177.html