codeforces-scrape

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

1366A.md (1220B)


      1 Source: https://codeforces.com/problemset/problem/1366/A
      2 
      3 A. Shovels and Swords
      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 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.
     22 
     23 Each tool can be sold for exactly one emerald. How many emeralds can Polycarp earn, if he has $a$ sticks and $b$ diamonds?
     24 
     25 Input
     26 
     27 The first line contains one integer $t$ ($1 \le t \le 1000$) — the number of test cases.
     28 
     29 The only line of each test case contains two integers $a$ and $b$ ($0 \le a, b \le 10^9$) — the number of sticks and the number of diamonds, respectively.
     30 
     31 Output
     32 
     33 For each test case print one integer — the maximum number of emeralds Polycarp can earn.
     34 
     35 Example
     36 
     37 Input
     38 
     39 ```
     40 4
     41 4 4
     42 1000000000 0
     43 7 15
     44 8 7
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 2
     51 0
     52 7
     53 5
     54 ```
     55 
     56 Note
     57 
     58 In the first test case Polycarp can earn two emeralds as follows: craft one sword and one shovel.
     59 
     60 In the second test case Polycarp does not have any diamonds, so he cannot craft anything.