Problem K
fingerpainting kits with between three and twelve 50ml bottles of
paint, each a different color. The paints are bright and fun to
work with, and have the useful property that if you mix X ml each
of any three different colors, you get X ml of gray. (The paints
are thick and "airy", almost like cake frosting, and when you mix
them together the volume doesn't increase, the paint just gets more
dense.) None of the individual colors are gray; the only way to get
gray is by mixing exactly three distinct colors, but it doesn't
matter which three. Your friend Emily is an elementary school
teacher and every Friday she does a fingerpainting project with her
class. Given the number of different colors needed, the amount of
each color, and the amount of gray, your job is to calculate the
number of kits needed for her class.
cases, followed by a line containing only zero that signals the end
of the input. Each test case consists of a single line of five or
more integers, which are separated by a space. The first integer N
is the number of different colors (3 <= N <= 12). Following
that are N different nonnegative integers, each at most 1,000, that
specify the amount of each color needed. Last is a nonnegative
integer G <= 1,000 that specifies the amount of gray needed. All
quantities are in ml.< br>
number of fingerpainting kits sufficient to provide the required
amounts of all the colors and gray. Note that all grays are
considered equal, so in order to find the minimum number of kits
for a test case you may need to make grays using different
combinations of three distinct colors.
0
250 0 60 0 500
95 10
95 11
333
ml混合而成,现在给出各个颜色的需求量,让你求最少需要几盒颜料;
0ms)
#include
#include
#include
#define maxn 20
using namespace std;
bool comp(const int &a,const int &b)
{
return
a>b;
}
int find_max(int color[],int n)
{
int
s=-1;
for(int
i=0;i
{
if(color[i]>s)
s=color[i];
}
return
s;
}
int main()
{
//freopen("in.txt", "r", stdin);
int
n,color[maxn],gray,kits=0,maxneed=0;
while(~scanf("%d",&n)&&n)
{
kits=maxneed=0;
for(int i=0;i
scanf("%d",&color[i]);
scanf("%d",&gray);
maxneed=find_max(color,n);
kits=maxneedP?maxneed/50+1:maxneed/50;//先满足别的颜色需求;
for(int i=0;i
color[i]=kits*50-color[i];//这是按照别的需求加满颜料之后的各种颜料
//的数量
int k=0;
while(true)//开始混合灰色的
{
if(k>=gray)
break;
sort(color,color+n,comp);
if(color[0]<=0||color[1]<=0||color[2]<=0)//如果有一种颜料不够了
{
kits++;
for(int i=0;i
color[i]+=50;//每一盒都加上50ml;
}
color[0]--;
color[1]--;
color[2]--;
k++;
}
printf("%d\n",kits);
}
return
0;
}
Problem K的更多相关文章
- Codeforces Gym 100610 Problem K. Kitchen Robot 状压DP
Problem K. Kitchen Robot Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10061 ...
- Codeforces 1089K - King Kog's Reception - [线段树][2018-2019 ICPC, NEERC, Northern Eurasia Finals Problem K]
题目链接:https://codeforces.com/contest/1089/problem/K time limit per test: 2 seconds memory limit per t ...
- Gym 101981K - Kangaroo Puzzle - [玄学][2018-2019 ACM-ICPC Asia Nanjing Regional Contest Problem K]
题目链接:http://codeforces.com/gym/101981/problem/K Your friend has made a computer video game called “K ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem K. UTF-8 Decoder 模拟题
Problem K. UTF-8 Decoder 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c702 ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem K. KMC Attacks 交互题 暴力
Problem K. KMC Attacks 题目连接: http://codeforces.com/gym/100714 Description Warrant VI is a remote pla ...
- XVII Open Cup named after E.V. Pankratiev Grand Prix of Moscow Workshops, Sunday, April 23, 2017 Problem K. Piecemaking
题目:Problem K. PiecemakingInput file: standard inputOutput file: standard outputTime limit: 1 secondM ...
- 2018 Multi-University Training Contest 4 Problem K. Expression in Memories 【模拟】
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6342 Problem K. Expression in Memories Time Limit: 200 ...
- HDU 6342.Problem K. Expression in Memories-模拟-巴科斯范式填充 (2018 Multi-University Training Contest 4 1011)
6342.Problem K. Expression in Memories 这个题就是把?变成其他的使得多项式成立并且没有前导零 官方题解: 没意思,好想咸鱼,直接贴一篇别人的博客,写的很好,比我的 ...
- 华农oj Problem K: 负2进制【有技巧构造/待补】
Problem K: 负2进制 Time Limit: 2 Sec Memory Limit: 128 MB Submit: 51 Solved: 6 [Submit][Status][Web Boa ...
- Problem K: 搜索基础之棋盘问题
Problem K: 搜索基础之棋盘问题 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 92 Solved: 53[Submit][Status][W ...
随机推荐
- Flex布局介绍
Flex 是 Flexible Box 的缩写,意为"弹性布局",用来为盒状模型提供最大的灵活性 任何一个容器都可以指定为 Flex 布局. .box{ display: -web ...
- mvc一对多模型表单的快速构建
功能需求描述 Q:在实际的开发中,经常会遇到一个模型中包含有多个条目的表单.如何将数据提交到后台? A: 以数组的形式提交到后台就Ok了(真的那么简单么,如果再嵌套一层呢?) A2:拆分多个模型,映射 ...
- java基础解析系列(七)---ThreadLocal原理分析
java基础解析系列(七)---ThreadLocal原理分析 目录 java基础解析系列(一)---String.StringBuffer.StringBuilder java基础解析系列(二)-- ...
- MySQL锁和事务(一):InnoDB锁(MySQL 官方文档粗翻)
// 写在前面,实际上,数据库加锁的类型和范围受到多种因素的影响,例如数据库隔离等级,SQL语句,是否使用主键.索引等等.可以查看博文: http://www.cnblogs.com/zhaoyl/p ...
- Vi快捷操作 vim配置【shell文件格式从windows转换为linux】
vim配置 http://www.cnblogs.com/ma6174/archive/2011/12/10/2283393.html gg 首行 dd 删除当前行 :.,$d 删除全部内容 :se ...
- Linux入门之常用命令(10)软连接 硬链接
在Linux系统中,内核为每一个新创建的文件分配一个Inode(索引结点),每个文件都有一个惟一的inode号.文件属性保存在索引结点里,在访问文件时,索引结点被复制到内存在,从而实现文件的快速访问. ...
- 【充分利用你的Azure】将Azure用作云计算平台(1)
本文将围绕几个步骤来讲. 因为本人是MSP,微软送了150刀的额度给我随便使用.这篇文章是要讲将Azure用作云计算平台,对于我来说,我是做机器学习的,那么Azure就要有机器学习的平台. 本文的目的 ...
- Mysql连接报错:1130-host ... is not allowed to connect to this MySql server如何处理
这个问题是因为在数据库服务器中的mysql数据库中的user的表中没有权限(也可以说没有用户),下面将记录我遇到问题的过程及解决的方法. 在搭建完LNMP环境后用Navicate连接出错 遇到这个问题 ...
- Docker 最常用的监控方案 - 每天5分钟玩转 Docker 容器技术(78)
当 Docker 部署规模逐步变大后,可视化监控容器环境的性能和健康状态将会变得越来越重要. 在本章中,我们将讨论几个目前比较常用的容器监控工具和方案,为大家构建自己的监控系统提供参考. 首先我们会讨 ...
- python 多线程和多进程的区别 mutiprocessing theading
多线程可以共享全局变量,多进程不能.多线程中,所有子线程的进程号相同:多进程中,不同的子进程进程号不同. #!/usr/bin/python # -*- coding:utf-8 -*- import ...