codeforces-scrape

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

1263A.md (1852B)


      1 Source: https://codeforces.com/problemset/problem/1263/A
      2 
      3 A. Sweet Problem
      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 You have three piles of candies: red, green and blue candies:
     22 
     23 * the first pile contains only red candies and there are $r$ candies in it,
     24 * the second pile contains only green candies and there are $g$ candies in it,
     25 * the third pile contains only blue candies and there are $b$ candies in it.
     26 
     27 Each day Tanya eats exactly two candies of different colors. She is free to choose the colors of eaten candies: the only restriction that she can't eat two candies of the same color in a day.
     28 
     29 Find the maximal number of days Tanya can eat candies? Each day she needs to eat exactly two candies.
     30 
     31 Input
     32 
     33 The first line contains integer $t$ ($1 \le t \le 1000$) — the number of test cases in the input. Then $t$ test cases follow.
     34 
     35 Each test case is given as a separate line of the input. It contains three integers $r$, $g$ and $b$ ($1 \le r, g, b \le 10^8$) — the number of red, green and blue candies, respectively.
     36 
     37 Output
     38 
     39 Print $t$ integers: the $i$-th printed integer is the answer on the $i$-th test case in the input.
     40 
     41 Example
     42 
     43 Input
     44 
     45 ```
     46 6
     47 1 1 1
     48 1 2 1
     49 4 1 1
     50 7 4 10
     51 8 1 4
     52 8 2 8
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 1
     59 2
     60 2
     61 10
     62 5
     63 9
     64 ```
     65 
     66 Note
     67 
     68 In the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.
     69 
     70 In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.
     71 
     72 In the third example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and red and blue candies on the second day. Note, that two red candies will remain uneaten.