End up with More Teams UVA - 11088
| Time Limit: 3000MS | Memory Limit: Unknown | 64bit IO Format: %lld & %llu |
Description
|
I I U P C 2 0 06 |
|
|
Problem E: End up with More Teams |
|
|
Input: standard input Output: standard output |
|
|
The prestigious ICPC is here again. The coaches are busy selecting teams. Well this year, they have adopted a new policy. Contrary to traditional selection process, where few individual contests are held and the top three are placed in one team the next three in another and so on, this year the coaches decided to place members in such a way that the total number of promising teams is maximized. Promising teams are defined as a team having ability points of its members adding up to 20 or greater. Here ability point of a member denotes his capability as a programmer, the higher the better. |
|
|
Input |
|
|
There will be as many as 100 cases in the input file. Each case of input has two lines. The first line contains a positive integer, where n indicates the number contestants available for selection. The next line will contain n positive integers, each of which will be at most 30. End of input is indicated by a value of 0 forn. |
|
|
Output |
|
|
For every case of input there will be one line of output. This line should contain the case number followed by the maximum number of promising teams that can be formed. Note that it is not mandatory to assign everyone in a team. Incase you dont know, each team consists of exactly 3 members. |
|
|
Constraints |
|
|
- n ≤ 15 |
|
|
Sample Input |
Output for Sample Input |
|
9 |
Case 1: 3 |
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int a[],b[],n,m,maxa;
bool cmp(int x,int y)
{
return x>y;
}
void dfs(int x,int cur)
{
int i,j,k,sum;
if(maxa<cur)maxa=cur;
if(maxa==m)
return;
for(i=x; i<n; i++)
{
if(!b[i])
for(j=i+; j<n; j++)
{
if(!b[j])
{
sum=a[i]+a[j];
for(k=j+; k<n; k++)
{
if(!b[k]&&sum+a[k]>=)break;
}
if(k<n)
{
b[i]=b[j]=b[k]=;
dfs(i+,cur+);
b[i]=b[j]=b[k]=;
}
}
}
}
}
int main()
{
int i,cas=;
while(~scanf("%d",&n),n)
{
maxa=;
memset(b,,sizeof(b));
for(i=; i<n; i++)scanf("%d",&a[i]);
sort(a,a+n);
m=n/;
dfs(n%,);
printf("Case %d: %d\n",cas++,maxa);
}
}
End up with More Teams UVA - 11088的更多相关文章
- Teams UVA - 11609
题意就不多说了这个小规律不算难,比较容易发现,就是让你求一个数n*2^(n-1):很好想只是代码实现起来还是有点小困(简)难(单)滴啦,一个快速幂就OK了: 代码: #include<stdio ...
- Teams UVA - 11609(快速幂板题)
写的话就是排列组合...但能化简...ΣC(n,i)*C(i,1) 化简为n*2^(n-1) ; #include <iostream> #include <cstdio> # ...
- uva 11088 暴力枚举子集/状压dp
https://vjudge.net/problem/UVA-11088 对于每一种子集的情况暴力枚举最后一个三人小组取最大的一种情况即可,我提前把三个人的子集情况给筛出来了. 即 f[S]=MAX{ ...
- UVA 11609 Teams 组合数学+快速幂
In a galaxy far far away there is an ancient game played among the planets. The specialty of the gam ...
- uva 10911 - Forming Quiz Teams(记忆化搜索)
题目链接:10911 - Forming Quiz Teams 题目大意:给出2 * n个选手的坐标, 要求将所有的选手分成n组, 每组两个人, 所有组的两个人之间的距离之和要最小, 输出最小值. 解 ...
- UVA 10911 Forming Quiz Teams(dp + 集合最优配对问题)
4th IIUC Inter-University Programming Contest, 2005 G Forming Quiz Teams Input: standard input Outpu ...
- UVA - 11609 Teams (排列组合数公式)
In a galaxy far far awaythere is an ancient game played among the planets. The specialty of the game ...
- UVA 11609 - Teams(二项式系数)
题目链接 想了一会,应该是跟二项式系数有关系,无奈自己推的式子,构不成二项式的系数. 选1个人Cn1*1,选2个人Cn2*2....这样一搞,以为还要消项什么的... 搜了一下题解,先选队长Cn1,选 ...
- UVa 11609 (计数 公式推导) Teams
n个人里选k个人有C(n, k)中方法,再从里面选一人当队长,有k中方法. 所以答案就是 第一步的变形只要按照组合数公式展开把n提出来即可. #include <cstdio> typed ...
随机推荐
- ScrollView嵌套ListView只显示一行
错误描述 ScrollView嵌套ListView中导致ListView高度计算不正确,只显示一行. 解决方法 重写ListView的onMeasure方法,代码如下. @Override publi ...
- 工具类:将其他编码类型转换成UTF-8或者其他类型的工具类
将其他编码类型转换成UTF-8或者其他类型的工具类 public static String changeUTF(String str) { String newStr = null; try { n ...
- PHP发送邮件功能--ThinkPHP3.2.3
首先第一步 :在网上down了一个PHPMailer插件,插件地址>https://github.com/PHPMailer/PHPMailer下载解压后,这里我们只需要用到其中两个文件,如 ...
- ActiveMQ笔记——技术点汇总
目录 · Introduction to ActiveMQ · Installing ActiveMQ · Message-oriented middleware · JMS specificatio ...
- HTTP协议知多少-关于http1.x、http2、SPDY的相关知识
作为网站开发的基础协议,我们知道浏览器上都有输出http这四个字母,这意味着什么呢? 这就是最基础的HTTP协议. 逐浪君今天为各位大人准备了一些HTTP技术的知识,来和大家分享. 以下图为例: 这一 ...
- 云计算的三种服务模式IaaS、PaaS和SaaS的差别
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt363 云服务"现在已经快成了一个家喻户晓的词了.如果你不知道Paa ...
- 201521123084 《Java程序设计》第4周学习总结
第4周作业-面向对象设计与继承 1. 本周学习总结 1.1 尝试使用思维导图总结有关继承的知识点. 1.2 使用常规方法总结其他上课内容. 总结: (1)学会了如何给类和方法进行简单的注释: (2)学 ...
- 201521123017 《Java程序设计》第6周学习总结
1. 本周学习总结 <> 2. 书面作业 Q1.clone方法 1.1 Object对象中的clone方法是被protected修饰,在自定义的类中覆盖clone方法时需要注意什么? 1. ...
- CMD命令查询DNS服务器
我们先了解"tracert"命令,如图 tracert命令 这是路由跟踪命令,你打开网站通过了哪些网关都能看出来,比如: tracert命令 这是路由跟踪命令,你打开网站通过了哪些 ...
- 201521123065《java程序设计》第12周学习总结
1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多流与文件相关内容. 1.流的划分:输入流:字节流(InputStream).字符流(reader): 输出流:字节流(Output ...