Recently, Kien has been addicted to playing a card game on the computer. One day, Kien…
- User
Recently, Kien has been addicted to playing a card game on the computer. One day, Kien brought his classmate Khanh home to visit after school. Khanh was introduced to the card game by Kien. The rules of the game are very simple. There are 2 × N cards, arranged in two rows, each row has N cards. The cards in the lower row belong to the player, while the cards in the upper row belong to the machine. Each card is written with an integer representing the strength of that card. The player and the machine are also given a non-negative integer M. First, the machine will randomly select two integers Xc and Kc satisfying 0 ≤ Xc ≤ [M/N] and 1 ≤ Kc ≤ N. The machine keeps these two integers secret, the player does not know. Then it is the player's turn to choose two integers Xp and Kp satisfying 0 ≤ Xp ≤ [M/N] and 1 ≤ Kp ≤ N.
When both the machine and the player have chosen their two numbers, the following operations will be performed:
The strength of the cards in the upper row is added an amount equal to Xc, except for the card in the Kc position in the upper row, an amount equal to (M – N × Xc) is added. The strength of the cards in the lower row is added an amount equal to Xp, except for the card in the Kp position in the lower row, an amount equal to (M – N × Xp) is added. After the above operations, we will compare the cards in the same position on the two rows. Specifically, let C[i] be the strength of the card in the i-th position in the top row (1 ≤ i ≤ N) and P[i] be the strength of the card in the i-th position in the bottom row (1 ≤ i ≤ N). At each i-th position among N positions, if C[i] > P[i], the machine gets 1 point, and if C[i] < P[i], the player gets 1 point. The player wins if the score is greater than the machine's score. For each option (Xp, Kp), we call its winning probability the number of pairs (Xc, Kc) that the machine chooses that lead to the player's victory. After explaining the rules of the game to Khanh, Kien let Khanh try playing a game. As soon as he saw 2 × N cards and the number M, Kien sighed: "With such a bad hand, how can I win?" But Khanh did not think so. Khanh told Kien: “Winning is good!”. Kien did not believe it, so he asked Khanh to prove that what he had just said was true. Requirement: Help Khanh prove his argument by finding the pair of integers (Xp, Kp) that gives the highest probability of winning.
The data includes: • The first line contains two positive integers N, M • The second line contains N integers with absolute values not exceeding 10^9 , which are the strength of the cards in the upper row that the machine owns. • The third line contains N integers with absolute values not exceeding 10^9 , which are the strength of the cards in the lower row that the player owns. Result: the two integers Xp and Kp that give the highest probability of winning, along with the probability of winning of the chosen option (Xp, Kp), all three numbers on a line and separated by a space. If there are multiple answers that have the highest probability of winning, print the answer with the lowest Xp. If there are still multiple answers with the same Xp value that have the highest probability of winning, print the answer with the lowest Kp.
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.