codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

519C.md (1862B)


      1 Source: https://codeforces.com/problemset/problem/519/C
      2 
      3 C. A and B and Team Training
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 A and B are preparing themselves for programming contests.
     22 
     23 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.
     24 
     25 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.
     26 
     27 However, B believes that the optimal team should have two experienced members plus one newbie. Thus, each newbie can gain more knowledge and experience.
     28 
     29 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.
     30 
     31 There are *n* experienced members and *m* newbies on the training session. Can you calculate what maximum number of teams can be formed?
     32 
     33 Input
     34 
     35 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.
     36 
     37 Output
     38 
     39 Print the maximum number of teams that can be formed.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 2 6
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 2
     53 ```
     54 
     55 Input
     56 
     57 ```
     58 4 5
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 3
     65 ```
     66 
     67 Note
     68 
     69 Let's represent the experienced players as XP and newbies as NB.
     70 
     71 In the first test the teams look as follows: (XP, NB, NB), (XP, NB, NB).
     72 
     73 In the second test sample the teams look as follows: (XP, NB, NB), (XP, NB, NB), (XP, XP, NB).