746D.md (1627B)
1 Source: https://codeforces.com/problemset/problem/746/D 2 3 D. Green and Black Tea 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 Innokentiy likes tea very much and today he wants to drink exactly *n* cups of tea. He would be happy to drink more but he had exactly *n* tea bags, *a* of them are green and *b* are black. 22 23 Innokentiy doesn't like to drink the same tea (green or black) more than *k* times in a row. Your task is to determine the order of brewing tea bags so that Innokentiy will be able to drink *n* cups of tea, without drinking the same tea more than *k* times in a row, or to inform that it is impossible. Each tea bag has to be used exactly once. 24 25 Input 26 27 The first line contains four integers *n*, *k*, *a* and *b* (1 ≤ *k* ≤ *n* ≤ 105, 0 ≤ *a*, *b* ≤ *n*) — the number of cups of tea Innokentiy wants to drink, the maximum number of cups of same tea he can drink in a row, the number of tea bags of green and black tea. It is guaranteed that *a* + *b* = *n*. 28 29 Output 30 31 If it is impossible to drink *n* cups of tea, print "NO" (without quotes). 32 33 Otherwise, print the string of the length *n*, which consists of characters 'G' and 'B'. If some character equals 'G', then the corresponding cup of tea should be green. If some character equals 'B', then the corresponding cup of tea should be black. 34 35 If there are multiple answers, print any of them. 36 37 Examples 38 39 Input 40 41 ``` 42 5 1 3 2 43 ``` 44 45 Output 46 47 ``` 48 GBGBG 49 ``` 50 51 Input 52 53 ``` 54 7 2 2 5 55 ``` 56 57 Output 58 59 ``` 60 BBGBGBB 61 ``` 62 63 Input 64 65 ``` 66 4 3 4 0 67 ``` 68 69 Output 70 71 ``` 72 NO 73 ```