628C.md (2024B)
1 Source: https://codeforces.com/problemset/problem/628/C 2 3 C. Bear and String Distance 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 Limak is a little polar bear. He likes nice strings — strings of length *n*, consisting of lowercase English letters only. 22 23 The distance between two letters is defined as the difference between their positions in the alphabet. For example, , and . 24 25 Also, the distance between two nice strings is defined as the sum of distances of corresponding letters. For example, , and . 26 27 Limak gives you a nice string *s* and an integer *k*. He challenges you to find any nice string *s*' that . Find any *s*' satisfying the given conditions, or print "-1" if it's impossible to do so. 28 29 As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java. 30 31 Input 32 33 The first line contains two integers *n* and *k* (1 ≤ *n* ≤ 105, 0 ≤ *k* ≤ 106). 34 35 The second line contains a string *s* of length *n*, consisting of lowercase English letters. 36 37 Output 38 39 If there is no string satisfying the given conditions then print "-1" (without the quotes). 40 41 Otherwise, print any nice string *s*' that . 42 43 Examples 44 45 Input 46 47 ``` 48 4 26 49 bear 50 ``` 51 52 Output 53 54 ``` 55 roar 56 ``` 57 58 Input 59 60 ``` 61 2 7 62 af 63 ``` 64 65 Output 66 67 ``` 68 db 69 ``` 70 71 Input 72 73 ``` 74 3 1000 75 hey 76 ``` 77 78 Output 79 80 ``` 81 -1 82 ```