John decided to eat nuts. He has $$$x$$$ nuts in a box. There are $$$n$$$ types of nuts in the box. The box contains $$$a_i$$$ nuts of i-th type.
John wants to eat only one nut, but this nut must be one of the $$$k$$$ defined types – $$$b_1, b_2, \ldots b_k$$$.
John starts taking nuts out of the box blindly. What's the minimum amount of nuts that John must take to guarantee in this 'taken' nuts, John will find the type, that he would like to eat?
The first line contains two integers $$$n, x$$$: $$$(1 \le n \le 10^5, 1 \le x \le 10^7)$$$.
The second line contains an array $$$a$$$ with $$$n$$$ integers: ($$$1 \le a_i \le x$$$). Note that $$$a_1 + a_2 + \ldots + a_n = x$$$.
The third line contains one integer $$$1 \le k \le n$$$.
The fourth line contains an array $$$b$$$ with $$$k$$$ different integers: $$$1 \le b_i \le n$$$, where $$$b_i$$$ – $$$i$$$-th type of nuts that John wants to eat.
Output a single number $$$answer$$$ – how many nuts John needs to take at least to guarantee that he will take the type of nut he wants to eat.
5 19 9 1 2 3 4 2 2 4
16
In the first test, John cannot draw $$$15$$$ nuts, as it may happen that he will draw $$$9$$$ nuts of type $$$1$$$, $$$2$$$ nuts of type $$$3$$$, and $$$4$$$ nuts of type $$$5$$$. It can be shown that $$$16$$$ nuts will always be enough.
John realized that he would not eat all nuts and decided to call his friend Katya (a fan of factorials). Katya suggests John to play a game:
There are $$$n$$$ factorials written on the board ($$$1!$$$, $$$2!$$$ , $$$3!$$$, ... $$$n!$$$), John goes first. John choose the number $$$i$$$, then if $$$i!$$$ is odd, then John gets one point, otherwise, Katya gets one point. Then Katya's turn, Katya chooses $$$i$$$, which hasn't chosen yet, and takes the product of two selected factorials (John's and Katya's). If product is odd, then John gets one point, otherwise, Katya gets one point.
And so on, every next move, we take the product of all the factorials that were chosen by John and Katya for all the time, then if $$$i!$$$ is odd, then John gets one point, otherwise, Katya gets one point.
The player who scores the most points wins.
Determine whether John can win if both players play optimally.
You have a number $$$n$$$ ($$$1 \le n \le 150$$$)
Write '$$$Win$$$' (without quotation marks), if John wins.
Write '$$$Draw$$$' (without quotation marks), if it will be a draw.
Write '$$$Lose$$$' (without quotation marks), if Katya wins.
1
Win
5
Lose
In the first test, the game will consist of one move. In this turn, John will call the number $$$1$$$, and get one point.
John and Katya are tired of eating nuts. They opened a quiz on Katya's phone, where an answer to the question is a certain non-negative integer.
Each of the two players calls the number and the one which number is closer to the answer wins. Formally, if the correct answer is $$$c$$$ the winner is the one with the minimum value of $$$|x-c|$$$, where $$$x$$$ is someone's answer. If the numbers $$$|x-c|$$$ are equal for both players, then there is no winner.
After a few rounds, John and Katya have relized that the bot that is playing against them will do everything possible to make them win.
John and Katya know that the answer to the question is the number $$$a$$$.
They are wondering if their answer to the question will be $$$b$$$, what is the minimum number that the bot will can output in order for them to win?
Two numbers in single line - $$$0 \le a, b \le 10^9$$$ - real answer to the question, John's and Katya's answer.
The minimum possible non-negative integer that the bot can output. If the bot hasn't option output the number $$$-1$$$.
2 6
7
0 9
10
In the first test, if the bot outputs the number $$$7$$$, John and Katya will win, since $$$|7 - 2| \gt |6 - 2|$$$. It can be shown that no number less than $$$7$$$ can be output by the bot.
Katya went home( John was very tired and hungry. He took a frozen pizza from a fridge to cook pizza by himself.
John is a very smart boy, he knows that if you cut the pizza into triangles, then more pizza will fit into the oven. John has endless supplies of hexagonal pizzas, each of these pizzas John cut into $$$6$$$ equilateral triangles with side $$$1$$$.
John has an oven of size $$$n * m$$$ in his flat. John's task is to place as many pieces of pizza in the oven as possible with only one condition. John likes when the pizza slices lie in the oven beautifully, so the boy needs to choose the side of the oven, and arrange all the pizza slices so that one side of each pizza slice is parallel to the selected side of the oven.
Help him find out how many pieces of pizza (equilateral triangles with side $$$1$$$) John can put in the oven.
You get two numbers $$$n, m$$$ ($$$1 \le n, m \le 10^{5}$$$)
Just find the answer)
1 1
1