CF1692H.Gambling

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Marian is at a casino. The game at the casino works like this.

Before each round, the player selects a number between 11 and 10910^9. After that, a dice with 10910^9 faces is rolled so that a random number between 11 and 10910^9 appears. If the player guesses the number correctly their total money is doubled, else their total money is halved.

Marian predicted the future and knows all the numbers x1,x2,…,xnx_1, x_2, \dots, x_n that the dice will show in the next nn rounds.

He will pick three integers aa, ll and rr (l≤rl \leq r). He will play r−l+1r-l+1 rounds (rounds between ll and rr inclusive). In each of these rounds, he will guess the same number aa. At the start (before the round ll) he has 11 dollar.

Marian asks you to determine the integers aa, ll and rr (1≤a≤1091 \leq a \leq 10^9, 1≤l≤r≤n1 \leq l \leq r \leq n) such that he makes the most money at the end.

Note that during halving and multiplying there is no rounding and there are no precision errors. So, for example during a game, Marian could have money equal to 11024\dfrac{1}{1024}, 1128\dfrac{1}{128}, 12\dfrac{1}{2}, 11, 22, 44, etc. (any value of 2t2^t, where tt is an integer of any sign).

玛丽安在一家赌场。赌场的游戏规则如下:

每轮开始前,玩家需选择一个介于 11 和 10910^9 之间的整数。随后,一枚拥有 10910^9 个面的骰子被掷出,随机产生一个介于 11 和 10910^9 之间的整数。若玩家猜中该数字,则其总金额翻倍;否则,其总金额减半。

玛丽安已预知未来,知晓接下来 nn 轮中骰子将依次显示的数字 x1,x2,…,xnx_1, x_2, \dots, x_n。

她将选定三个整数 aa、ll 和 rr(满足 l≤rl \leq r)。她将参与第 ll 轮至第 rr 轮(含端点),共 r−l+1r-l+1 轮。在这些轮次中,她每轮均猜测同一个数字 aa。初始时(即第 ll 轮开始前),她拥有 11 美元。

玛丽安请你确定整数 aa、ll 和 rr(满足 1≤a≤1091 \leq a \leq 10^9,1≤l≤r≤n1 \leq l \leq r \leq n),使得她在所有轮次结束后获得的金额最大。

注意:在每次乘以 22 或除以 22 的过程中不进行任何舍入,且不存在精度误差。因此,例如,在游戏过程中,玛丽安的金额可能为 11024\dfrac{1}{1024}、1128\dfrac{1}{128}、12\dfrac{1}{2}、11、22、44 等(即任意形如 2t2^t 的值,其中 tt 为任意整数,可正可负)。

输入格式

The first line contains a single integer tt (1≤t≤1001 \leq t \leq 100) — the number of test cases.

The first line of each test case contains a single integer nn (1≤n≤2⋅1051 \leq n \leq 2\cdot 10^5) — the number of rounds.

The second line of each test case contains nn integers x1,x2,…,xnx_1, x_2, \dots, x_n (1≤xi≤1091 \leq x_i \leq 10^9), where xix_i is the number that will fall on the dice in the ii-th round.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052\cdot10^5.

第一行包含一个整数 tt(1≤t≤1001 \leq t \leq 100),表示测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1≤n≤2⋅1051 \leq n \leq 2\cdot 10^5),表示轮数。

每个测试用例的第二行包含 nn 个整数 x1,x2,…,xnx_1, x_2, \dots, x_n(1≤xi≤1091 \leq x_i \leq 10^9),其中 xix_i 表示第 ii 轮中骰子掷出的数字。

保证所有测试用例的 nn 之和不超过 2⋅1052\cdot10^5。

输出格式

For each test case, output three integers aa, ll, and rr such that Marian makes the most amount of money gambling with his strategy. If there are multiple answers, you may output any of them.

对于每个测试用例,输出三个整数 aa、ll 和 rr,使得 Marian 采用其策略进行赌博时能赚取最多的钱。如果存在多个答案,你可以输出其中任意一个。

输入输出样例

  • 输入#1

    4
    5
    4 4 3 4 4
    5
    11 1 11 1 11
    1
    1000000000
    10
    8 8 8 9 9 6 6 9 6 6

    输出#1

    4 1 5
    1 2 2
    1000000000 1 1
    6 6 10

说明/提示

For the first test case, the best choice is a=4a=4, l=1l=1, r=5r=5, and the game would go as follows.

  • Marian starts with one dollar.
  • After the first round, he ends up with 22 dollars because the numbers coincide with the chosen one.
  • After the second round, he ends up with 44 dollars because the numbers coincide again.
  • After the third round, he ends up with 22 dollars because he guesses 44 even though 33 is the correct choice.
  • After the fourth round, he ends up with 44 dollars again.
  • In the final round, he ends up 88 dollars because he again guessed correctly.

There are many possible answers for the second test case, but it can be proven that Marian will not end up with more than 22 dollars, so any choice with l=rl = r with the appropriate aa is acceptable.

对于第一个测试用例,最优选择是 a=4a=4、l=1l=1、r=5r=5,游戏过程如下:

  • 玛丽安初始拥有 1 美元。
  • 第一轮结束后,他拥有 2 美元,因为所出现的数字与选定的数字一致。
  • 第二轮结束后,他拥有 4 美元,因为所出现的数字再次与选定的数字一致。
  • 第三轮结束后,他拥有 2 美元,因为他猜了 44,但正确答案是 33。
  • 第四轮结束后,他再次拥有 4 美元。
  • 最后一轮结束后,他拥有 8 美元,因为他再次猜对了。

第二个测试用例存在多种可能的答案,但可以证明玛丽安最终拥有的金额不会超过 2 美元,因此任何满足 l=rl = r 且取适当 aa 的选择均可接受。

输入解题思路,AI测评打分。不知道怎么写?

首页