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 ...
随机推荐
- Git命令家底儿及Git数据通信原理详解
http://geek.csdn.net/news/detail/72807?utm_source=tuicool&utm_medium=referral
- [原] Jenkins Android 自动打包配置
一.Jenkins自动打包配置 目标:1. 自动打包:2. 自动上传:3. 友好下载 1. Jenkins简介 Jenkins是基于Java开发的一种持续集成工具,用于监控持续重复的工作. 减少重复劳 ...
- Linux(Red Hat)-中安装Vmware Tools
0. 会弹出 ***1.在弹出的文件夹中找到"VMwwareTools9.6.2-1688356.tar.gz",右击"解压缩到"...我解压缩到了" ...
- 安装cocopods
http://www.tuicool.com/articles/7VvuAr3 OS 最新版 CocoaPods 的安装流程 1.移除现有Ruby默认源 $gem sources --remove h ...
- QT连接Linux mysql注意
windows: #define MYSQLDB "QMYSQL"#define MYSQLDB_HOSTNAME "192.168.228.168"#defi ...
- VS上利用C#实现一个简单的串口程序记录
一.背景 工作上需要利用串口往下位机写入数据,VC太老,正好借此机会来熟悉一直很想接触的VS之C#. 感谢Tony托尼哥的串口通信代码,感谢梦真的C#的技术支持. 二.正文 1.项目架构:(以我现有的 ...
- 【转】将datatable数据转化成list
#region 将datatable数据转化成list public static List<T> ToList<T>(this DataTable dt) where T ...
- Sqli-LABS通关笔录-12
通过这个关卡我学习到了: 1.双引号千万别忘记,就是因为忘了弄了好一会儿.一直不报错. 2. 00x1万能密码构造二 报错的内容为: You have an error in your SQL syn ...
- 顺序栈的c++实现及利用其实现括号的匹配
#include<iostream>#include<cassert>#include<cstring>#include<string>using na ...
- linux 权限操作
添加用户 命令格式:useradd 选项 用户名 -g 缺省组(不写则默认为用户名组) -G 所属组(添加到多个用户组,逗号隔开) -c 描述信息 -d 指定家目录 useradd –g aa bb ...