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 n towers from them, where the i-th tower has height hi cubes.
Egor and Arseniy must choose an integer xi for each tower i and increase its height by xi exactly once. For example, if h = [1,3,2,2], x = [3,2,2,8], then after increasing h it will become [4,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 k and add a restriction: each xi must satisfy 1≤xi≤k. Help him find the smallest k for which it is possible to finish the game.
达比尔、叶戈尔和阿尔谢尼刚刚上了一列火车,决定玩一个游戏。达比尔的背包里有无限多个立方体,他用它们搭建了 n 座塔,其中第 i 座塔的高度为 hi 个立方体。
叶戈尔和阿尔谢尼必须为每座塔 i 选择一个整数 xi,并对该塔的高度恰好增加一次 xi。例如,若 h=[1,3,2,2],x=[3,2,2,8],则增加后 h 将变为 [4,5,4,10]。他们的目标是使所有塔的高度相等。
为了使游戏更有趣,达比尔希望选择一个整数 k,并添加一条限制:每个 xi 必须满足 1≤xi≤k。请帮助他找出能够完成该游戏的最小 k。
输入格式
The first line contains a single integer t (1≤t≤104) — the number of test cases.
Then t test cases follow.
The first line of each test case contains a single integer n (1≤n≤5).
The second line contains n integers h1,h2,…,hn (1≤hi≤6).
第一行包含一个整数 t(1≤t≤104)—— 测试用例的数量。
接下来是 t 个测试用例。
每个测试用例的第一行包含一个整数 n(1≤n≤5)。
第二行包含 n 个整数 h1,h2,…,hn(1≤hi≤6)。
输出格式
For each test case, output a single integer — the minimum value of k such that it is possible to make all towers have equal height.
对于每个测试用例,输出一个整数——使得所有塔的高度相等所需的最小 k 值。
输入输出样例
输入#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测评打分。不知道怎么写?