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
output
input
output
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; }
相关文章推荐
- Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) A
- Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2)A
- Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) C
- Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) B
- Technocup 2017 - Elimination Round 1 (Rated for Div. 2) C. Guess the Array 交互题+解n元方程组
- Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) E
- Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)
- Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) E. Santa Claus and Tangerines
- codeforces Technocup 2017 - Elimination Round 2/Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2) 题解
- Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2)
- 【解题报告】Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2)
- Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2)
- Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 – Elimination Round 2) A. Interview wi
- Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2) E. Subordinates 贪心
- Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) A
- Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) F
- Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) 圣诞之夜!
- Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) D
- Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)
- Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2)C. Road to Cinema 二分