CF2236A.Games on the Train

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Dabir, Egor, and Arseniy just got on the train and decided to play a game. Dabir has a backpack with an infinite number of cubes. He built nn towers from them, where the ii-th tower has height hih_i cubes.

Egor and Arseniy must choose an integer xix_i for each tower ii and increase its height by xix_i exactly once. For example, if hh = [1,3,2,21, 3, 2, 2], xx = [3,2,2,83, 2, 2, 8], then after increasing hh it will become [4,5,4,104, 5, 4, 10]. Their goal is to make the heights of all towers equal.

To make the game more interesting, Dabir wants to choose an integer kk and add a restriction: each xix_i must satisfy 1≤xi≤k1 \le x_i \le k. Help him find the smallest kk for which it is possible to finish the game.

达比尔、叶戈尔和阿尔谢尼刚刚上了一列火车,决定玩一个游戏。达比尔的背包里有无限多个立方体,他用它们搭建了 nn 座塔,其中第 ii 座塔的高度为 hih_i 个立方体。

叶戈尔和阿尔谢尼必须为每座塔 ii 选择一个整数 xix_i,并对该塔的高度恰好增加一次 xix_i。例如,若 h=[1,3,2,2]h = [1, 3, 2, 2],x=[3,2,2,8]x = [3, 2, 2, 8],则增加后 hh 将变为 [4,5,4,10][4, 5, 4, 10]。他们的目标是使所有塔的高度相等。

为了使游戏更有趣,达比尔希望选择一个整数 kk,并添加一条限制:每个 xix_i 必须满足 1≤xi≤k1 \le x_i \le k。请帮助他找出能够完成该游戏的最小 kk。

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

Then tt test cases follow.

The first line of each test case contains a single integer nn (1≤n≤51 \le n \le 5).

The second line contains nn integers h1,h2,…,hnh_1, h_2, \dots, h_n (1≤hi≤61 \le h_i \le 6).

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 测试用例的数量。

接下来是 tt 个测试用例。

每个测试用例的第一行包含一个整数 nn(1≤n≤51 \le n \le 5)。

第二行包含 nn 个整数 h1,h2,…,hnh_1, h_2, \dots, h_n(1≤hi≤61 \le h_i \le 6)。

输出格式

For each test case, output a single integer — the minimum value of kk such that it is possible to make all towers have equal height.

对于每个测试用例,输出一个整数——使得所有塔的高度相等所需的最小 kk 值。

输入输出样例

  • 输入#1

    4
    2
    1 3
    3
    2 6 4
    5
    5 4 6 6 1
    4
    3 3 3 3

    输出#1

    3
    5
    6
    1

说明/提示

null

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

首页