codeforces 519C. A and B and Team Training 解题报告
题目链接: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 解题报告的更多相关文章
- 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 ...
- codeforces 489C.Given Length and Sum of Digits... 解题报告
题目链接:http://codeforces.com/problemset/problem/489/C 题目意思:给出 m 和 s,需要构造最大和最小的数.满足长度都为 m,每一位的数字之和等于 s. ...
- Winter-2-STL-G Team Queue 解题报告及测试数据
Time Limit:3000MS Memory Limit:0KB Description Queues and Priority Queues are data structures wh ...
- codeforces 454B. Little Pony and Sort by Shift 解题报告
题目链接:http://codeforces.com/problemset/problem/454/B 题目意思:给出一个序列你 a1, a2, ..., an. 问每次操作只能通过将最后一个数拿出来 ...
- [codeforces contest 1119 F] Niyaz and Small Degrees 解题报告 (树形DP+堆)
interlinkage: http://codeforces.com/contest/1119/problem/F description: 有一颗$n$个节点的树,每条边有一个边权 对于一个$x$ ...
- Codeforces Round #335 (Div. 2)B. Testing Robots解题报告
B. Testin ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 【最新】2015年7月之15个最新jQuery插件
Hello,一个激动人心的好消息,现在我为大家整理最近7月发布的jQuery插件. 如果你熟悉任何下面列出的插件,请分享你的反馈与我们的读者,或如果你知道哪一个我们没有收录,那么请与我们分享在下面的评 ...
- 关于使用jacob出现的异常
1) 把jacob.jar加载到工程里:2) 把jacob.dll放入 JAVA_HOME\bin\ 和 JAVA_HOME\jre\bin目录下:3) 把jacob.dll放入 C:\WINDOW ...
- 关于Html编码问题,例如字符:·
我写的WCF服务突然报错了... 然后我发现传过来的字符不完整 {"完整":"尼古拉·奥斯特洛夫斯基的信息"} 然后传过来的是:{"完整": ...
- Swift---TextView用法
1.TextView放在一个NSScrollView中,作为documentView存在. @IBOutlet weak var txtScrollView: NSScrollView! 2.在Tex ...
- Wdcp在安装memcached出现错误的解决办法
今天在安装memcached时出现了以下错误(tar: libevent-1.4.14b-stable.tar.gz: Cannot open: No such file or directory), ...
- java之BASE64加解密
1.简介 Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一,采用Base64编码具有不可读性,即所编码的数据不会被人用肉眼所直接看到. 注:位于jdk的java.util包中. 2. ...
- Android快速开发系列 10个常用工具类
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/38965311,本文出自[张鸿洋的博客] 打开大家手上的项目,基本都会有一大批的辅 ...
- java 自定义标签 传值
<?xml version="1.0" encoding="UTF-8" ?> <taglib xmlns="http://ja ...
- 霸气!Nginx 中缓存静态文件秘籍
导读 这篇教程说明你应该怎样配置 nginx.设置 HTTP 头部过期时间,用 Cache-Control 中的 max-age 标记为静态文件(比如图片. CSS 和 Javascript 文件)设 ...
- Visual Studio error C2001:常量中有换行符(解决办法)
在Visual Studio自动生成的项目中,碰见了一件关于文件编码的问题,集中在类似于以下的语句上: DASLog (DASProtWarn, L"(%s)消息超时,进入慢循环召唤模式.& ...