codeforces 519C.. A and B and Team Training
1 second
256 megabytes
standard input
standard output
A and B are preparing themselves for programming contests.
An important part of preparing for a competition is sharing programming knowledge from the experienced members to those who are just beginning to deal with the contests. Therefore, during the next team training A decided to make teams so that newbies are solving problems together with experienced participants.
A believes that the optimal team of three people should consist of one experienced participant and two newbies. Thus, each experienced participant can share the experience with a large number of people.
However, B believes that the optimal team should have two experienced members plus one newbie. Thus, each newbie can gain more knowledge and experience.
As a result, A and B have decided that all the teams during the training session should belong to one of the two types described above. Furthermore, they agree that the total number of teams should be as much as possible.
There are n experienced members and m newbies on the training session. Can you calculate what maximum number of teams can be formed?
The first line contains two integers n and m (0 ≤ n, m ≤ 5·105) — the number of experienced participants and newbies that are present at the training session.
Print the maximum number of teams that can be formed.
2 6
2
4 5
3
Let's represent the experienced players as XP and newbies as NB.
In the first test the teams look as follows: (XP, NB, NB), (XP, NB, NB).
In the second test sample the teams look as follows: (XP, NB, NB), (XP, NB, NB), (XP, XP, NB).
存在两种情况,要么两个高手带一个新手,要么一个高手带两个新手。
很简单的。
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cctype>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#define LL long long
#define PF(x) ((x)*(x))
#define LF(x) ((x)*PF(x)) using namespace std;
const int INF=<<-;
const int max9=1e9;
const int max6=1e6;
const int max3=1e3; int gcd(int a,int b)
{
return b==?a:gcd(b,a%b);
} int main()
{
int n,m;
while(cin >> n >> m)
{
int Ans=(n+m)/;
Ans=min(Ans,n);
Ans=min(Ans,m);
cout << Ans << endl;
}
return ;
}
codeforces 519C.. A and B and Team Training的更多相关文章
- codeforces   519C. A and B and Team Training   解题报告
		
题目链接:http://codeforces.com/contest/519/problem/C 题目意思:给出 n 个 experienced participants 和 m 个 newbie ...
 - 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 ...
 - codeforces水题100道 第十一题 Codeforces Round #143 (Div. 2) A. Team (brute force)
		
题目链接:http://www.codeforces.com/problemset/problem/231/A题意:问n道题目当中有多少道题目是至少两个人会的.C++代码: #include < ...
 - Codeforces Round #235 (Div. 2)   C. Team
		
C. Team time limit per test 1 second memory limit per test 256 megabytes input standard input output ...
 - Codeforces Round #279 (Div. 2) A. Team Olympiad 水题
		
#include<stdio.h> #include<iostream> #include<memory.h> #include<math.h> usi ...
 - cf519C. A and B and Team Training(找规律)
		
题意 $a$个学生,$b$个教练 可以两个学生和一个教练一组,也可以两个教练和一个学生一组,问最多组成多少组 Sol 发题解的目的是为了纪念一下自己的错误思路 刚开始想的是:贪心的选,让少的跟多的分在 ...
 - 【Henu ACM Round#15 C】 A and B and Team Training
		
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举第一种方法. 剩下的全都个第二种方法. 看看能组成多少个队伍就可以了. [代码] #include <bits/stdc+ ...
 
随机推荐
- HTML5简单入门系列(八)
			
前言 本篇介绍HTML5中相对复杂的一些APIs,其中的数学知识比较多.虽然如此,但是其实API使用起来还是比较方便的. 这里说明一下,只写出API相关的JS代码,因为他们都是基于一个canvas标签 ...
 - NodeJS和C++的性能比较(转)
			
原文地址: http://www.web-tinker.com/article/20374.html 前段时间做了个实验,测试了1E9次的空循环在NodeJS和C++中的执行用时.于是我和小伙伴们瞬间 ...
 - nginx+keepalived+tomcat之tomcat性能调优
			
body{ font-family: Nyala; font-size: 10.5pt; line-height: 1.5;}html, body{ color: ; background-color ...
 - js阻止元素的默认事件与冒泡事件
			
嵌套的div元素,如果父级和子元素都绑定了一些事件,那么在点击最内层子元素时可能会触发父级元素的事件,从而带来一定的影响. 1. event.preventDefault(); -- 阻止元素的默认 ...
 - Win32 API中的user32.dll中的ShowWindow方法参数整理
			
在使用ShowWindow方法来设置窗体的状态时,由于不知道参数值,用起来非常容易混乱,所以整理了以下其参数的枚举值,方便以后的的使用. public class User32API { #reg ...
 - js 创建对象
			
1.工厂模式 function createPerson(name, age, job) { var o = new Object(); o.name = name; o.age = age; o.j ...
 - HttpApplication实战大文件上传 (第四篇)
			
一.Asp.net中的文件上传 在Asp.net 1.1中,文件在上传过程中将被全部保存在内存中,对于大文件来说,会造成内存空间的过度使用,可能会招致恶意攻击.为了解决这个问题,Asp.net在配置文 ...
 - Bucket Sort
			
(referrence: GeekforGeeks) Bucket sort is mainly useful when input is uniformly distributed over a r ...
 - ZOJ 1136 Multiple (BFS)
			
Multiple Time Limit: 10 Seconds Memory Limit: 32768 KB a program that, given a natural number N ...
 - Linux进程笔记
			
进程及作业管理 Uninterruptible sleep: 不可中断的睡眠Interruptible sleep:可中断睡眠 kernel:init: COW: Copy On Write, 写时复 ...