1355D.md (1535B)
1 Source: https://codeforces.com/problemset/problem/1355/D 2 3 D. Game With Array 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 Petya and Vasya are competing with each other in a new interesting game as they always do. 22 23 At the beginning of the game Petya has to come up with an array of $N$ positive integers. Sum of all elements in his array should be equal to $S$. Then Petya has to select an integer $K$ such that $0 \leq K \leq S$. 24 25 In order to win, Vasya has to find a non-empty subarray in Petya's array such that the sum of all selected elements equals to either $K$ or $S - K$. Otherwise Vasya loses. 26 27 You are given integers $N$ and $S$. You should determine if Petya can win, considering Vasya plays optimally. If Petya can win, help him to do that. 28 29 Input 30 31 The first line contains two integers $N$ and $S$ ($1 \leq N \leq S \leq 10^{6}$) — the required length of the array and the required sum of its elements. 32 33 Output 34 35 If Petya can win, print "YES" (without quotes) in the first line. Then print Petya's array in the second line. The array should contain $N$ positive integers with sum equal to $S$. In the third line print $K$. If there are many correct answers, you can print any of them. 36 37 If Petya can't win, print "NO" (without quotes). 38 39 You can print each letter in any register (lowercase or uppercase). 40 41 Examples 42 43 Input 44 45 ``` 46 1 4 47 ``` 48 49 Output 50 51 ``` 52 YES 53 4 54 2 55 ``` 56 57 Input 58 59 ``` 60 3 4 61 ``` 62 63 Output 64 65 ``` 66 NO 67 ``` 68 69 Input 70 71 ``` 72 3 8 73 ``` 74 75 Output 76 77 ``` 78 YES 79 2 1 5 80 4 81 ```