codeforces-scrape

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

105A.md (3313B)


      1 Source: https://codeforces.com/problemset/problem/105/A
      2 
      3 A. Transmigration
      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 In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes are characterized by different skills.
     22 
     23 Unfortunately, the skills that are uncommon for the given character's class are quite difficult to obtain. To avoid this limitation, there is the so-called transmigration.
     24 
     25 Transmigration is reincarnation of the character in a new creature. His soul shifts to a new body and retains part of his experience from the previous life.
     26 
     27 As a result of transmigration the new character gets all the skills of the old character and the skill levels are reduced according to the *k* coefficient (if the skill level was equal to *x*, then after transmigration it becomes equal to [*kx*], where [*y*] is the integral part of *y*). If some skill's levels are strictly less than 100, these skills are forgotten (the character does not have them any more). After that the new character also gains the skills that are specific for his class, but are new to him. The levels of those additional skills are set to 0.
     28 
     29 Thus, one can create a character with skills specific for completely different character classes via transmigrations. For example, creating a mage archer or a thief warrior is possible.
     30 
     31 You are suggested to solve the following problem: what skills will the character have after transmigration and what will the levels of those skills be?
     32 
     33 Input
     34 
     35 The first line contains three numbers *n*, *m* and *k* — the number of skills the current character has, the number of skills specific for the class into which the character is going to transmigrate and the reducing coefficient respectively; *n* and *m* are integers, and *k* is a real number with exactly two digits after decimal point (1 ≤ *n*, *m* ≤ 20, 0.01 ≤ *k* ≤ 0.99).
     36 
     37 Then follow *n* lines, each of which describes a character's skill in the form "*name* *exp*" — the skill's name and the character's skill level: *name* is a string and *exp* is an integer in range from 0 to 9999, inclusive.
     38 
     39 Then follow *m* lines each of which contains names of skills specific for the class, into which the character transmigrates.
     40 
     41 All names consist of lowercase Latin letters and their lengths can range from 1 to 20 characters, inclusive. All character's skills have distinct names. Besides the skills specific for the class into which the player transmigrates also have distinct names.
     42 
     43 Output
     44 
     45 Print on the first line number *z* — the number of skills the character will have after the transmigration. Then print *z* lines, on each of which print a skill's name and level, separated by a single space. The skills should be given in the lexicographical order.
     46 
     47 Examples
     48 
     49 Input
     50 
     51 ```
     52 5 4 0.75  
     53 axe 350  
     54 impaler 300  
     55 ionize 80  
     56 megafire 120  
     57 magicboost 220  
     58 heal  
     59 megafire  
     60 shield  
     61 magicboost
     62 ```
     63 
     64 Output
     65 
     66 ```
     67 6  
     68 axe 262  
     69 heal 0  
     70 impaler 225  
     71 magicboost 165  
     72 megafire 0  
     73 shield 0
     74 ```