codeforces-scrape

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

1250L.md (3142B)


      1 Source: https://codeforces.com/problemset/problem/1250/L
      2 
      3 L. Divide The Students
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 512 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 A group of students has recently been admitted to the Faculty of Computer Sciences at the Berland State University. Now the programming teacher wants to divide them into three subgroups for practice sessions.
     22 
     23 The teacher knows that a lot of programmers argue which language is the best. The teacher doesn't want to hear any arguments in the subgroups, so she wants to divide the students into three subgroups so that no pair of students belonging to the same subgroup want to argue.
     24 
     25 To perform this division, the teacher asked each student which programming language he likes. There are $a$ students who answered that they enjoy Assembler, $b$ students stated that their favourite language is Basic, and $c$ remaining students claimed that C++ is the best programming language — and there was a large argument between Assembler fans and C++ fans.
     26 
     27 Now, knowing that Assembler programmers and C++ programmers can start an argument every minute, the teacher wants to divide the students into three subgroups so that every student belongs to exactly one subgroup, and there is no subgroup that contains at least one Assembler fan and at least one C++ fan. Since teaching a lot of students can be difficult, the teacher wants the size of the largest subgroup to be minimum possible.
     28 
     29 Please help the teacher to calculate the minimum possible size of the largest subgroup!
     30 
     31 Input
     32 
     33 The first line contains one integer $t$ ($1 \le t \le 5$) — the number of test cases in the input. Then test cases follow.
     34 
     35 Each test case consists of one line containing three integers $a$, $b$ and $c$ ($1 \le a, b, c \le 1000$) — the number of Assembler fans, Basic fans and C++ fans, respectively.
     36 
     37 Output
     38 
     39 For each test case print one integer — the minimum size of the largest subgroup if the students are divided in such a way that there is no subgroup that contains at least one Assembler fan and at least one C++ fan simultaneously.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 5
     47 3 5 7
     48 4 8 4
     49 13 10 13
     50 1000 1000 1000
     51 13 22 7
     52 ```
     53 
     54 Output
     55 
     56 ```
     57 5
     58 6
     59 13
     60 1000
     61 14
     62 ```
     63 
     64 Input
     65 
     66 ```
     67 5
     68 1 3 4
     69 1000 1000 1
     70 4 1 2
     71 325 226 999
     72 939 861 505
     73 ```
     74 
     75 Output
     76 
     77 ```
     78 3
     79 667
     80 3
     81 517
     82 769
     83 ```
     84 
     85 Note
     86 
     87 Explanation of the answers for the example $1$:
     88 
     89 1. The first subgroup contains $3$ Assembler fans and $2$ Basic fans, the second subgroup — $5$ C++ fans, the third subgroup — $2$ C++ fans and $3$ Basic fans.
     90 2. The first subgroup contains $4$ Assembler fans, the second subgroup — $6$ Basic fans, the third subgroup — $2$ Basic fans and $4$ C++ fans.
     91 3. The first subgroup contains all Assembler fans, the second subgroup — all Basic fans, the third subgroup — all C++ fans.
     92 4. The first subgroup contains all Assembler fans, the second subgroup — all Basic fans, the third subgroup — all C++ fans.
     93 5. The first subgroup contains $12$ Assembler fans and $2$ Basic fans, the second subgroup — $1$ Assembler fan and $13$ Basic fans, the third subgroup — $7$ Basic fans and $7$ C++ fans.