题目链接:http://codeforces.com/contest/519/problem/C

题目意思:给出 n 个  experienced participants  和 m 个 newbies ,需要组成尽量多的组,组由3个人组成。有两种组合方式:(1)1 个 experienced participant 和 2 个  newbie  (2)2 个

experienced participant 和 1 个  newbie。问最多能组成的组数是多少组。

  昨天做的时候不是暴力做的,惯性思维所害!以为只有两种情况:尽可能多的方式(1) 或者尽可能多的方式(2)。这样做一直过不了pretest 5!

  暴力改回就过了!

 #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std; int cal(int n, int m)
{
int res = ;
for (int i = ; i <= n; i++) {
int tn = min(i, m/);
int tm = m - tn*;
int t = min((n-i)/, tm);
res = max(res, tn+t);
}
return res;
} int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE int n, m;
while (scanf("%d%d", &n, &m) != EOF) {
printf("%d\n", max(cal(n, m), cal(m, n)));
}
return ;
}

PS: 纪念第300篇博客完成[^__^] !!毕业设计完成前最后一篇博客!答辩后再见!

codeforces 519C. A and B and Team Training 解题报告的更多相关文章

  1. codeforces 519C.. A and B and Team Training

    C. A and B and Team Training time limit per test 1 second memory limit per test 256 megabytes input ...

  2. codeforces 489C.Given Length and Sum of Digits... 解题报告

    题目链接:http://codeforces.com/problemset/problem/489/C 题目意思:给出 m 和 s,需要构造最大和最小的数.满足长度都为 m,每一位的数字之和等于 s. ...

  3. Winter-2-STL-G Team Queue 解题报告及测试数据

    Time Limit:3000MS     Memory Limit:0KB Description Queues and Priority Queues are data structures wh ...

  4. codeforces 454B. Little Pony and Sort by Shift 解题报告

    题目链接:http://codeforces.com/problemset/problem/454/B 题目意思:给出一个序列你 a1, a2, ..., an. 问每次操作只能通过将最后一个数拿出来 ...

  5. [codeforces contest 1119 F] Niyaz and Small Degrees 解题报告 (树形DP+堆)

    interlinkage: http://codeforces.com/contest/1119/problem/F description: 有一颗$n$个节点的树,每条边有一个边权 对于一个$x$ ...

  6. Codeforces Round #335 (Div. 2)B. Testing Robots解题报告

                                                                                               B. Testin ...

  7. Codeforces Round #294 (Div. 2)C - A and B and Team Training 水题

    C. A and B and Team Training time limit per test 1 second memory limit per test 256 megabytes input ...

  8. CF A and B and Team Training (数学)

    A and B and Team Training time limit per test 1 second memory limit per test 256 megabytes input sta ...

  9. 294 div2 C. A and B and Team Training

    C. A and B and Team Training 题目:A and B are preparing themselves for programming contests. An import ...

随机推荐

  1. [设计模式] javascript 之 迭代子模式

    迭代子模式:定义 迭代子模式,又称游标模式,是一种用于对聚集进行顺序访问规则的模式,是一种行为模式:它用于提供对聚集对象的一种统一的访问接口,使客户能够在不了解聚集对象内部结构的情况对聚集对象进行访问 ...

  2. 存储过程获取最后插入到数据表里面的ID

    存储过程获取最后插入到数据表里面的ID SET NOCOUNT on;---不返回影响行数提高性能GOcreate proc [sp_bbs_thread_Insert] @id int output ...

  3. VTK初学一,b_PolyVertex_CellArray多个点的绘制

    #ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRend ...

  4. php实现图片缩放功能类

    http://www.poluoluo.com/jzxy/201312/255447.html <?php /** * Images类是一个图片处理类 * @package applicatio ...

  5. tomcat JNDI 设置

    一.在Spring配置文件中的配置   <bean id="dataSource" class="org.springframework.jndi.JndiObje ...

  6. git上传github上

    1.git init --初始化git   (选择文件夹) 2.git add README  --添加项目(项目的文件夹) 3.git commit -m "SSM(360)" ...

  7. Laravel 5.1 文档攻略 —— Eloquent:模型对象序列化

    在写api的时候,数据一般是以json格式进行传输的,没有对象可以直接使用.这个时候,对数据的序列化转换就很重要,Eloquent提供了很方便的方法和约定,不仅可以转换,还可以控制里面的键值. 基本用 ...

  8. velocity +mybatis+ springMvc构建邮件服务器知识总结

    1.在controller中传值到页面 (1)List<String> 类型 List<String> servers = null ; //…………………… mv.addOb ...

  9. PHP运算符:算数运算符、逻辑运算符、三目运算符、位运算符、字符串运算符。

    赋值运算符 PHP 赋值运算符用于向变量写值. PHP 中基础的赋值运算符是 "=". 这意味着右侧复制表达式会为左侧运算数设置值. _______________________ ...

  10. PyCharm 入手第一记

    因为我是忠实的Linux用户,所以一下操作是在Linux下的完成,除了下载,因为Linux的下载着实有点让人捉急. PyCharm 下载地址: http://www.jetbrains.com/pyc ...