您的位置:首页 > 运维架构

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

2017-07-26 23:15 549 查看
Theorganizersofaprogrammingcontesthavedecidedtopresentt-shirtstoparticipants.Therearesixdifferentt-shirtssizesinthisproblem:S,M,L,XL,XXL,XXXL(sizesarelistedinincreasingorder).Thet-shirtsarealreadyprepared.ForeachsizefromStoXXXLyouaregiventhenumberoft-shirtsofthissize.

Duringtheregistration,theorganizersaskedeachofthenparticipantsaboutthet-shirtsizehewants.Ifaparticipanthesitatedbetweentwosizes,hecouldspecifytwoneighboringsizes—thismeansthatanyofthesetwosizessuitshim.

Writeaprogramthatwilldeterminewhetheritispossibletopresentat-shirttoeachparticipantofthecompetition,ornot.Ofcourse,eachparticipantshouldgetat-shirtofpropersize:

thesizehewanted,ifhespecifiedonesize;

anyofthetwoneibouringsizes,ifhespecifiedtwosizes.

Ifitispossible,theprogramshouldfindanyvaliddistributionofthet-shirts.

Input
Thefirstlineoftheinputcontainssixnon-negativeintegers—thenumberoft-shirtsofeachsize.ThenumbersaregivenforthesizesS,M,L,XL,XXL,XXXL,respectively.Thetotalnumberoft-shirtsdoesn'texceed100 000.

Thesecondlinecontainspositiveintegern(1 ≤ n ≤ 100 000)—thenumberofparticipants.

Thefollowingnlinescontainthesizesspecifiedbytheparticipants,onelineperparticipant.Thei-thlinecontainsinformationprovidedbythei-thparticipant:singlesizeortwosizesseparatedbycomma(withoutanyspaces).Iftherearetwosizes,thesizesarewritteninincreasingorder.Itisguaranteedthattwosizesseparatedbycommaareneighboring.

Output
Ifitisnotpossibletopresentat-shirttoeachparticipant,print«NO»(withoutquotes).

Otherwise,printn + 1lines.Inthefirstlineprint«YES»(withoutquotes).Inthefollowingnlinesprintthet-shirtsizestheorginizersshouldgivetoparticipants,oneperline.Theorderoftheparticipantsshouldbethesameasintheinput.

Iftherearemultiplesolutions,printanyofthem.

Examples

input
010110
3
XL
S,M
XL,XXL


output
YES
XL
M
XXL


input
112011
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>
usingnamespacestd;
map<string,int>Mp,mp;
inta[10];
strings[100010];
strings2[100010];
strings3[7]={"","S","M","L","XL","XXL","XXXL"};
stringss[6]={"","S,M","M,L","L,XL","XL,XXL","XXL,XXXL"};
vector<string>Ve;
intmain(){
mp["S"]=1;
mp["M"]=2;
mp["L"]=3;
mp["XL"]=4;
mp["XXL"]=5;
mp["XXXL"]=6;
Mp["S,M"]=1;
Mp["M,L"]=2;
Mp["L,XL"]=3;
Mp["XL,XXL"]=4;
Mp["XXL,XXXL"]=5;
for(inti=1;i<=6;i++){
cin>>a[i];
}//cout<<a[mp["XXL"]]<<endl;
intm;
cin>>m;
for(inti=1;i<=m;i++){
cin>>s[i];
if(Mp[s[i]]==0){
a[mp[s[i]]]--;
}
}
for(inti=1;i<=6;i++){
if(a[i]<0){
cout<<"NO"<<endl;
return0;
}
}
for(inti=1;i<=5;i++){
for(intj=1;j<=m;j++){
if(ss[i]==s[j]){
if(a[Mp[s[j]]]){
a[Mp[s[j]]]--;
s[j]=s3[Mp[s[j]]];
}elseif(a[Mp[s[j]]+1]){
a[Mp[s[j]]+1]--;
s[j]=s3[Mp[s[j]]+1];
}else{
cout<<"NO"<<endl;
return0;
}
}
}
}
cout<<"YES"<<endl;
for(inti=1;i<=m;i++){
cout<<s[i]<<endl;
}
return0;
}



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐