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 ...
随机推荐
- 公司python入职培训流程
时间分为4周,全部自学,仅提供大纲.适用于Web方向:1.Week1:读完<简明Python教程>,适应Python开发环境2.Week2:写个爬虫,需要深入了解re.urllib2.s ...
- chrome开发工具指南(十三)
模拟传感器:地理定位与加速度计 由于大多数桌面设备都没有 GPS 芯片和加速度计,所以测试它们比较困难.Chrome DevTools 的 Sensors 模拟窗格可以通过模拟常见的移动设备传感器来降 ...
- poj 2553 强连通
题意:给出一个有向图,定义:若节点v所有能到达的点{wi},都能反过来到达v,那么称节点v是sink.题目要求所有的sink点. 思路:强连通缩点找出出度为零的点,输出即可. 这题主要问题是读题,了解 ...
- C# XmlDocument操作XML
XML:Extensible Markup Language(可扩展标记语言)的缩写,是用来定义其它语言的一种元语言,其前身是SGML(Standard Generalized Markup Lang ...
- AppiumDesktop用法介绍
转自:http://www.jianshu.com/p/bf1ca3d4ac76 写这篇文章的心情 真的很开心,我看着官网介绍竟然对AppiumDesktop略懂皮毛了.今天特意写出来,希望可以帮助一 ...
- 团队作业8——第二次项目冲刺(Beta阶段)5.20
1.当天站立式会议照片 会议内容: 本次会议为第二次会议 本次会议在陆大楼2楼召开,本次会议内容: ①:检查第一次任务完成情况 ②:做第二次任务的详细分工 ③:规定完成时间是在第三次任务之前 ④:遇到 ...
- 201521123038 《Java程序设计》 第六周学习总结
201521123038 <Java程序设计> 第六周学习总结 1. 本周学习总结 2. 书面作业 1.clone方法 1.1 Object对象中的 clone 方法是被protected ...
- 201521123076《Java程序设计》第2周学习总结
1.本周学习总结 ①学会简单地管理原始码与位码文档(包的概念) ②了解了一些新的名词,如:完全限定(吻合)名 ③String类相关 ④in.nextInt(),in.next(),in.nextLin ...
- 201521123017 《Java程序设计》第14周学习总结
1. 本周学习总结 2. 书面作业 Q1.MySQL数据库基本操作 建立数据库,将自己的姓名.学号作为一条记录插入.(截图,需出现自己的学号.姓名) 在自己建立的数据库上执行常见SQL语句(截图) - ...
- 201521123074 《Java程序设计》第14周学习总结
1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多数据库相关内容. 2. 书面作业 Q1. MySQL数据库基本操作 建立数据库,将自己的姓名.学号作为一条记录插入.(截图,需出现 ...