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 ...
随机推荐
- 【转】个人总结-网络安全学习和CTF必不可少的一些网站
转自:http://blog.csdn.net/ida0918/article/details/52730662 学习的地方很多,不能一一列举,一些优秀的网址和博客可能也没有提到,大家补充吧:P就简单 ...
- firefox下reset()不好使的问题
最近在测试项目时发现,在firefox下,form.reset()方法对于隐藏的<input>等不起效果,导致程序中出现了错误,以下面为例: js代码: document.agentFor ...
- websevice之三要素
SOAP(Simple Object Access Protocol).WSDL(WebServicesDescriptionLanguage).UDDI(UniversalDescriptionDi ...
- jquery日期和时间的插件精确到秒
首先.html5提供了input的time类型,使我们可以通过input框输入日期,但是如果我们的需求是这个时间需要明确到几时几分几秒的,那html5就没有办法满足我们的需求了,就需要使用jQuery ...
- OC基础:block.字面量 分类: ios学习 OC 2015-06-22 19:08 155人阅读 评论(0) 收藏
block 块语法,可以用block去保存一段代码,或者封装一段代码. block 实际是由c语言实现的,执行效率很高. block 实际借鉴了函数指针的语法. block,在多线程.异步任务,集合遍 ...
- STM32 LSM6DSL 陀螺仪数据采集
/************************************************************************************ * STM32 LSM6DS ...
- 如何查看linux系统的版本信息
前言 有时候需要查看linux系统的版本信息,本文将对此简单介绍. 方法 1.输入"uname -a ",可显示电脑以及操作系统的相关信息. 2.输入"cat /etc/ ...
- windows7所有版本迅雷地址下载集合(含32位和64位) - imsoft.cnblogs
Windows7 SP1旗舰版 32位官方原版下载: ed2k://|file|/cn_windows_7_ultimate_with_sp1_x86_dvd_618763.iso|265187737 ...
- 线程池、及使用场景、线程安全封装、ConcurrentHashMap应用场景
https://blog.csdn.net/sinbadfreedom/article/details/80467253 :1.HashMap与ConcurrentHashMap的区别与应用场景 h ...
- 【maven】使用import scope解决maven继承(单)问题
测试环境 maven 3.3.9 想必大家在做SpringBoot应用的时候,都会有如下代码: <parent> <groupId>org.springframework.bo ...