POJ 2706 Painter
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 3157 | Accepted: 1962 |
Description
Input
Output
Sample Input
3 40 95 21 0
7 25 60 400 250 0 60 0 500
4 90 95 75 95 10
4 90 95 75 95 11
5 0 0 0 0 0 333
0
Sample Output
2
8
2
3
4
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
int n;
int i;
int a[];
int t;
int num;
while (cin >> n && n)
{
for (i = ; i <= n; i++) cin >> a[i];
cin >> t;
num = ;
sort(a + , a + + n);
int k = a[n] / ;
if (k* < a[n]) k++;//先配自己的颜料
for (i = ; i <= n; i++)
{
a[i] = k * - a[i];
}
num += k;
sort(a + , a + + n);//要排序切记
while (t--)
{
bool f = ;
for (i = n; i >=n-; i--)
{
a[i]--;
if (a[i] < && f == )//如果不够了
{
f = ;
}
}
if (f)
{
num++;//不够就加一套
for (i = ; i<=n;i++)
{
a[i] += ; }
}
sort(a + , a + + n);//要排序
}
cout << num << endl;
}
return ;
}
POJ 2706 Painter的更多相关文章
- poj 1681 Painter's Problem
Painter's Problem 题意:给一个n*n(1 <= n <= 15)具有初始颜色(颜色只有yellow&white两种,即01矩阵)的square染色,每次对一个方格 ...
- POJ 1681 Painter's Problem 【高斯消元 二进制枚举】
任意门:http://poj.org/problem?id=1681 Painter's Problem Time Limit: 1000MS Memory Limit: 10000K Total ...
- OpenJudge 2813 画家问题 / Poj 1681 Painter's Problem
1.链接地址: http://bailian.openjudge.cn/practice/2813 http://poj.org/problem?id=1681 2.题目: 总时间限制: 1000ms ...
- POJ 1681 Painter's Problem(高斯消元+枚举自由变元)
http://poj.org/problem?id=1681 题意:有一块只有黄白颜色的n*n的板子,每次刷一块格子时,上下左右都会改变颜色,求最少刷几次可以使得全部变成黄色. 思路: 这道题目也就是 ...
- poj 1681 Painter's Problem(高斯消元)
id=1681">http://poj.org/problem? id=1681 求最少经过的步数使得输入的矩阵全变为y. 思路:高斯消元求出自由变元.然后枚举自由变元,求出最优值. ...
- POJ 1681 Painter's Problem (高斯消元)
题目链接 题意:有一面墙每个格子有黄白两种颜色,刷墙每次刷一格会将上下左右中五个格子变色,求最少的刷方法使得所有的格子都变成yellow. 题解:通过打表我们可以得知4*4的一共有4个自由变元,那么我 ...
- POJ 1681 Painter's Problem (高斯消元 枚举自由变元求最小的步数)
题目链接 题意: 一个n*n 的木板 ,每个格子 都 可以 染成 白色和黄色,( 一旦我们对也个格子染色 ,他的上下左右 都将改变颜色): 给定一个初始状态 , 求将 所有的 格子 染成黄色 最少需要 ...
- POJ 1681 Painter's Problem [高斯消元XOR]
同上题 需要判断无解 需要求最小按几次,正确做法是枚举自由元的所有取值来遍历变量的所有取值取合法的最小值,然而听说数据太弱自由元全0就可以就水过去吧.... #include <iostream ...
- poj很好很有层次感(转)
OJ上的一些水题(可用来练手和增加自信) (POJ 3299,POJ 2159,POJ 2739,POJ 1083,POJ 2262,POJ 1503,POJ 3006,POJ 2255,POJ 30 ...
随机推荐
- python 抓取request信息,各种cookie,user-agent类的信息,只调试到http可以抓取,https貌似不行。
import pcap # 安装的是pypcap,本博客有安装方法,不过也比较乱,试试吧.import dpktimport socketimport datetime def sniffer(str ...
- property 的详细使用方法
property(fget=None, fset=None, fdel=None, doc=None) 俗话说条条大路通罗马,同样是完成一件事,Python 其实提供了好几个方式供你选择. prop ...
- 关于RM中的X3014错误,以及mul() 、天空盒
关于 error X3014: incorrect number of arguments to numeric-type constructor 这个错误应该是某个类似float4 这样的变量初始 ...
- java学习笔记 --- 集合(续)
1.map集合 1.1.特点:将键映射到值的对象.一个映射不能包含重复的键:每个键最多只能映射到一个值. 1.2.Map集合和Collection集合的区别? Map集合存储元素是成对出现的,Map集 ...
- log4j的配置详解(转)
转自:http://blog.sina.com.cn/s/blog_5ed94d710101go3u.html 最近使用log4j写log时候发现网上的写的都是千篇一律,写的好的嘛不全,写的全一点的嘛 ...
- NodeJS 难点(网络,文件)的 核心 stream 二:stream是什么
对于大部分有后端经验的的同学来说 Stream 对象是个再合理而常见的对象,但对于前端同学 Stream 并不是那么理所当然,github 上甚至有一篇 9000 多 Star 的文章介绍到底什么是 ...
- c# winform 中DataGridView绑定List<T> 不能显示数据
遇到问题 DataGridView绑定List后,List更新后再次绑定不显示数据 datagridview 绑定数据源的时候 用List是不能显示修改内容的..要用binginglist<T& ...
- git添加本地项目到git
1.切换到项目所在文件夹下:git int 2.git add -A 3.git commit -m '11' 4.git remote add origin https://github.com/g ...
- 如何更改/删除magento首页产品/广告图片等模块信息
如何更改/删除magento首页产品/广告图片等模块信息,如果只是修改一些简单的地方,例如已经存在 的左右栏目里面的图片内容等,是很简单的,直接在后台就可以修改的,具体如下: 如何删除magento首 ...
- 20155229 2016-2017-2 《Java程序设计》第五周学习总结
20155229 2016-2017-2 <Java程序设计>第五周学习总结 教材学习内容总结 第八章: Java中所有错误都会被打包为对象. 设计错误对象都继承自java.lang.Th ...