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. ansible快速学习

    推荐文献: 表述的很不错, http://www.mamicode.com/info-detail-1428476.html 附加参考: http://laowafang.blog.51cto.com ...

  2. codeforces B. Ping-Pong (Easy Version) 解题报告

    题目链接:http://codeforces.com/problemset/problem/320/B 题目意思:有两种操作:"1 x y"  (x < y) 和 " ...

  3. codeforces B. Polo the Penguin and Matrix 解题报告

    题目链接:http://codeforces.com/problemset/problem/289/B 题目意思:给出一个 n 行 m 列的矩阵和数值 d .通过对矩阵里面的数进行 + d 或者 - ...

  4. python3 安装 opencv3 (win10,64bit)

    python3只能安装opencv3  (python2安装opencv应该比python3安装的要简单,可参阅网上其他教程)   步骤参考http://stackoverflow.com/quest ...

  5. CentOS7设置系统/yum以及firefox web代理上网

    一.系统全局的代理设置: 用vi/vim编辑器打开/etc/profile,追加如下内容: http_proxy=http://192.168.78.124:8080 ftp_proxy=http:/ ...

  6. POJ2406(next原理理解)

    Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 40448   Accepted: 16828 D ...

  7. Storm 01之 Storm基本概念及第一个demo

    2.1 Storm基本概念 在运行一个Storm任务之前,需要了解一些概念: Topologies :[tə'pɑ:lədʒɪ]拓扑结构 Streams Spouts:[spaʊt]喷出; 喷射; 滔 ...

  8. android 收集的一些颜色值

    <?xml version="1.0" encoding="utf-8"?> <resources> <color name=&q ...

  9. zabbix snmp、jmx配置使用

    SNMP: snmp是很古老的监控,我萌几乎可以在所有设备上看到它的身影 [root@linux-node1 ~]# yum install net-snmp net-snmp-libs net-sn ...

  10. KVM虚拟机内无agent情况下的监控方法

    KVM虚拟机内无agent情况下的监控(ceilometer实现) 今天看到大家在群里讨论KVM虚拟机的监控问题,而且是要求VM内无agent情况下的监控.这方面确实没有深入研究,但尚有些openst ...