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 ...
随机推荐
- NOIP[2015] Day2题解
问题 A: 跳石头 时间限制: 1 Sec 内存限制: 128 MB 题目描述 一年一度的"跳石头"比赛又要开始了! 这项比赛将在一条笔直的河道中进行,河道中分布着一些巨大岩石. ...
- 【拦截器】HandlerInterceptor接口
package org.springframework.web.servlet; import javax.servlet.http.HttpServletRequest; import javax. ...
- java面向对象(四)之重写、重载
重载 定义 重载:在一个类中,存在多个方法拥有相同的名字,但在名字相同的同时,必须有不同的参数,这就是重载. 编译器会根据实际情况挑选出正确的方法,如果编译器找不到匹配的参数或者找出多个可能的匹配就会 ...
- 使用 PUTTY 操作 Google Cloud
目的: 使用putty连接Google Cloud 实例. 总说: 首先要用 PuTTYgen生成 private key 和 public key, 之后 登录Google Cloud 将生成的 ...
- Netty自娱自乐之类Dubbo RPC 框架设计构想 【上篇】
之前在前一篇的<Netty自娱自乐之协议栈设计>,菜鸟我已经自娱自乐了设计协议栈,gitHub地址为https://github.com/vOoT/ncustomer-protocal.先 ...
- Project 8:利用递归算法求最大值
目标:用递归算法实现求一个数组中的最大元素. 样例输入 5 1 4 2 5 3 样例输出 5 #include <stdio.h> int max(int *,int); int main ...
- 我的hibernate学习记录(二)
通过上一篇文章我的hibernate学习记录(一)基本上的入门了hibernate,但是,里面还有还多东西是通过迷迷糊糊的记忆,或者说copy直接弄进去的,所以这篇文章就需要对上篇的一些文件.对象进行 ...
- RobotFramework自动化测试框架-移动手机自动化测试Input Text和Click Button关键字的使用
Input Text和Click Button Input Text 关键字一般用来给输入框进行输入操作,该关键字接收两个参数[ locator | text ]. 示例1:启动安卓手机上一个APP的 ...
- Bootstrap框架的了解和使用(一)
前 言 Bootstrap 什么是 Bootstrap?Bootstrap 是一个用于快速开发 Web 应用程序和网站的前端框架.Bootstrap 是基于 HTML.CSS.JavaScrip ...
- 团队作业8——第二次项目冲刺(Beta阶段)--第二天
团队作业8--第二次项目冲刺(Beta阶段)--第二天 会议照片: 燃尽图: 项目进展: 今天完成了记录用户的姓名,其他的任务还在跟进. 团队贡献比: 队员 角色 团队贡献比 陈麟凤 PM 16% 张 ...