Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) D
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.
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.
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.
0 1 0 1 1 0
3
XL
S,M
XL,XXL
YES
XL
M
XXL
1 1 2 0 1 1
5
S
M
S,M
XXL,XXXL
XL,XXL
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的更多相关文章
- 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, ...
- 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. ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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,到每 ...
随机推荐
- 最优配对问题(集合上的动态规划) —— 状压DP
题目来源:紫书P284 题意: 给出n个点的空间坐标(n为偶数, n<=20), 把他们配成n/2对, 问:怎样配对才能使点对的距离和最小? 题解: 设dp[s]为:状态为s(s代表着某个子集) ...
- 近期测试BUG总结
前些日子上线了新版的app,在上线后发现了几个重大的bug,在此总结,在以后的测试工作中需要额外的关注. 需求流程bug 页面刷新bug 标签栏刷新bug 第一个bug出现的原因是产品需求与运营实际操 ...
- python写excel
例一,普通写入: # -*-coding: utf-8-*- import xlwt workbook = xlwt.Workbook() sheet = workbook.add_sheet('sh ...
- netty ssl
netty提供的例子中有secury的实现,不过是一个伪证书.修改了一下其中的SecureChatSslContextFactory类,使用证书的方式实现ssl.修改后代码如下: public fin ...
- iptables 端口映射
一.环境和要实现功能 PC1的网络设置如下: eth0 192.168.0.29 内网 eth1 219.239.11.22 外网 PC2的网络设置则为:192.168.0.21 内网 我 ...
- 微信小程序把玩(三十)wx.request(object) API
这里通过干活集中营的API接口真实请求下数据.如果提示URL 域名不合法,请在 mp 后台配置后重试修改asdebug.js两行代码即可可看下面图 百牛信息技术bainiu.ltd整理发布于博客园 定 ...
- docker --help 详解
[root@c1 _src]# dockerd --help Usage: dockerd [OPTIONS] A self-sufficient runtime for containers. Op ...
- SSAS GUID 添加 行计数,非重复计数 等 遇到的莫名其妙的问题
在基于某个GUID 进行非重复性计数时 需要对GUID 转换类型,如:CAST(ColumnName as varchar(36)) 可参考:http://stackoverflow.com/ques ...
- ping测试网络
https://jingyan.baidu.com/article/ac6a9a5e109d5f2b653eacbc.html 百度百科:https://baike.baidu.com/item/pi ...
- ubuntu系统下挂载新的硬盘
参考 http://zwkufo.blog.163.com/blog/static/258825120141283942244/ http://blog.csdn.net/caicai2526 ...