codeforces-scrape

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

90A.md (2755B)


      1 Source: https://codeforces.com/problemset/problem/90/A
      2 
      3 A. Cableway
      4 
      5 time limit per test
      6 
      7 2 seconds
      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 group of university students wants to get to the top of a mountain to have a picnic there. For that they decided to use a cableway.
     22 
     23 A cableway is represented by some cablecars, hanged onto some cable stations by a cable. A cable is scrolled cyclically between the first and the last cable stations (the first of them is located at the bottom of the mountain and the last one is located at the top). As the cable moves, the cablecar attached to it move as well.
     24 
     25 The number of cablecars is divisible by three and they are painted three colors: red, green and blue, in such manner that after each red cablecar goes a green one, after each green cablecar goes a blue one and after each blue cablecar goes a red one. Each cablecar can transport no more than two people, the cablecars arrive with the periodicity of one minute (i. e. every minute) and it takes exactly 30 minutes for a cablecar to get to the top.
     26 
     27 All students are divided into three groups: *r* of them like to ascend only in the red cablecars, *g* of them prefer only the green ones and *b* of them prefer only the blue ones. A student never gets on a cablecar painted a color that he doesn't like,
     28 
     29 The first cablecar to arrive (at the moment of time 0) is painted red. Determine the least time it will take all students to ascend to the mountain top.
     30 
     31 Input
     32 
     33 The first line contains three integers *r*, *g* and *b* (0 ≤ *r*, *g*, *b* ≤ 100). It is guaranteed that *r* + *g* + *b* > 0, it means that the group consists of at least one student.
     34 
     35 Output
     36 
     37 Print a single number — the minimal time the students need for the whole group to ascend to the top of the mountain.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 1 3 2
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 34
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 3 2 1
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 33
     63 ```
     64 
     65 Note
     66 
     67 Let's analyze the first sample.
     68 
     69 At the moment of time 0 a red cablecar comes and one student from the *r* group get on it and ascends to the top at the moment of time 30.
     70 
     71 At the moment of time 1 a green cablecar arrives and two students from the *g* group get on it; they get to the top at the moment of time 31.
     72 
     73 At the moment of time 2 comes the blue cablecar and two students from the *b* group get on it. They ascend to the top at the moment of time 32.
     74 
     75 At the moment of time 3 a red cablecar arrives but the only student who is left doesn't like red and the cablecar leaves empty.
     76 
     77 At the moment of time 4 a green cablecar arrives and one student from the *g* group gets on it. He ascends to top at the moment of time 34.
     78 
     79 Thus, all the students are on the top, overall the ascension took exactly 34 minutes.