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

Source: Internet
Author: User

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

C. A and B and Team Trainingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard 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 fig.

A believes that the optimal team of three people shoshould consist of one experienced participant and two newbies. Thus, each experienced participant ipant can share the experience with a large number of people.

However, B believes that the optimal team showould 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 shoshould belong to one of the two types described above. furthermore, they agree that the total number of teams shocould be as much as possible.

There areNExperienced members andMNewbies on the training session. Can you calculate what maximum number of teams can be formed?

Input

The first line contains two integersNAndM(0? ≤?N,?M? ≤? 5. 105)-the number of experienced participant ipants and newbies that are present at the training session.

Output

Print the maximum number of teams that can be formed.

Sample test (s) input
2 6
Output
2
Input
4 5
Output
3
Note

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 ).





Idea: Try to maximize that teams.


AC code:

#include 
 
  #include 
  
   #include 
   
    #include #include 
    
     using namespace std;int main() {int n, m;while(scanf("%d %d", &n, &m) != EOF) {int a = (m + n) / 3;int ans = min(a, min(n, m));printf("%d\n", ans);}return 0;}
    
   
  
 












Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.