codeforces-scrape

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

24B.md (2670B)


      1 Source: https://codeforces.com/problemset/problem/24/B
      2 
      3 B. F1 Champions
      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 Formula One championship consists of series of races called Grand Prix. After every race drivers receive points according to their final position. Only the top 10 drivers receive points in the following order 25, 18, 15, 12, 10, 8, 6, 4, 2, 1. At the conclusion of the championship the driver with most points is the champion. If there is a tie, champion is the one with most wins (i.e. first places). If a tie still exists, it is chosen the one with most second places, and so on, until there are no more place to use for compare.
     22 
     23 Last year another scoring system was proposed but rejected. In it the champion is the one with most wins. If there is tie, champion is the one with most points. If a tie still exists it is proceeded the same way as in the original scoring system, that is comparing number of second, third, forth, and so on, places.
     24 
     25 You are given the result of all races during the season and you are to determine the champion according to both scoring systems. It is guaranteed, that both systems will produce unique champion.
     26 
     27 Input
     28 
     29 The first line contain integer *t* (1 ≤ *t* ≤ 20), where *t* is the number of races. After that all races are described one by one. Every race description start with an integer *n* (1 ≤ *n* ≤ 50) on a line of itself, where *n* is the number of clasified drivers in the given race. After that *n* lines follow with the classification for the race, each containing the name of a driver. The names of drivers are given in order from the first to the last place. The name of the driver consists of lowercase and uppercase English letters and has length at most 50 characters. Comparing of names should be case-sensetive.
     30 
     31 Output
     32 
     33 Your output should contain exactly two line. On the first line is the name of the champion according to the original rule, and on the second line the name of the champion according to the alternative rule.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 3  
     41 3  
     42 Hamilton  
     43 Vettel  
     44 Webber  
     45 2  
     46 Webber  
     47 Vettel  
     48 2  
     49 Hamilton  
     50 Vettel
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 Vettel  
     57 Hamilton
     58 ```
     59 
     60 Input
     61 
     62 ```
     63 2  
     64 7  
     65 Prost  
     66 Surtees  
     67 Nakajima  
     68 Schumacher  
     69 Button  
     70 DeLaRosa  
     71 Buemi  
     72 8  
     73 Alonso  
     74 Prost  
     75 NinoFarina  
     76 JimClark  
     77 DeLaRosa  
     78 Nakajima  
     79 Patrese  
     80 Surtees
     81 ```
     82 
     83 Output
     84 
     85 ```
     86 Prost  
     87 Prost
     88 ```
     89 
     90 Note
     91 
     92 It is not guaranteed that the same drivers participate in all races. For the championship consider every driver that has participated in at least one race. The total number of drivers during the whole season is not more then 50.