题目翻译:

Yelisey has an array a of n integers.

数组a中有n个整数

If a has length strictly greater than 1, then Yelisei can apply an operation called minimum extraction to it:

a如果的长度严格大于1,那么可以对其实行最小抽离操作

  1. First, Yelisei finds the minimal(最小的) number m in the array. If there are several identical minima, Yelisey can choose any of them.
  2. Then the selected minimal element is removed from the array. After that, m is subtracted from each remaining element

该操作规则:

1.首先,找到a中最小的数m,如果有多个最小值,只要任意选其中一个

2.然后,从a中去除该最小元素,然后使剩余的每一个元素减去m

Thus, after each operation, the length of the array is reduced by 1.

因此,在操作若干次后,a的长度会减到1

For example, if a=[1,6,−4,−2,−4]a=[1,6,−4,−2,−4], then the minimum element in it is a3=−4a3=−4, which means that after this operation the array will be equal to a=[1−(−4),6−(−4),−2−(−4),−4−(−4)]=[5,10,2,0]a=[1−(−4),6−(−4),−2−(−4),−4−(−4)]=[5,10,2,0].

Since Yelisey likes big numbers, he wants the numbers in the array a to be as big as possible.

要求:a中的数尽可能的大

Formally speaking, he wants to make the minimum of the numbers in array a to be maximal possible (i.e. he want to maximize a minimum). To do this, Yelisey can apply the minimum extraction operation to the array as many times as he wants (possibly, zero). Note that the operation cannot be applied to an array of length 1.

即:a中的最小值尽可能的大

为了使a的最小值尽可能的大,可以对a进行最小抽离操作(0或多次)

Help him find what maximal(最大值) value can the minimal element of the array have after applying several (possibly, zero) minimum extraction operations to the array.

问题:找出对a进行最小提取操作若干次(或者0次)后a中最小值的最大值

Input

The first line contains an integer tt (1≤t≤1041≤t≤104) — the number of test cases.

The next 2t lines contain descriptions of the test cases.

In the description of each test case, the first line contains an integer n(1≤n≤2⋅1051≤n≤2⋅105) — the original length of the array a. The second line of the description lists n space-separated integers ai (−109≤ai≤109−109≤ai≤109) — elements of the array a.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052⋅105.

输入:

第一行case个数

下面每两行一组,每组第一行记录数组整数个数,第二行是具体数组

Output

Print t lines, each of them containing the answer to the corresponding test case. The answer to the test case is a single integer — the maximal possible minimum in aa, which can be obtained by several applications of the described operation to it.

输出:每一个case的经过最小抽离操作后最小值的最大值

问题概述:

数组a有n个数,操作:去掉最小值后让其余每个元素减去最小值

求经过若干次操作后最小值的最大值

思路:

多写几个找规律,发现排序后第n个相邻两个相减就是对应操作n次后的最小值

代码:

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;long long  minimum(vector<long long>& nums)
{long long  n = nums.size();long long  maxmin = INT64_MIN;sort(nums.begin() + 1, nums.end());if (nums.size() == 2){return nums[1];}maxmin = nums[1];for (long long i = 1; i < n - 1; i++){maxmin = max(maxmin, nums[i + 1] - nums[i]);}return maxmin;}
int main()
{long long m;cin >> m;long long len;long long elem;vector<vector<long long>>vec;vector<long long>temp;while (m--){cin >> len;temp.push_back(len);for (long long i = 0; i < len; i++){cin >> elem;temp.push_back(elem);}vec.push_back(temp);temp.clear();}for (long long i = 0; i < vec.size(); i++){cout << minimum(vec[i]) << endl;}
}

Codeforces Round #753 (Div. 3) C. Minimum Extraction(最小抽离)相关推荐

  1. Codeforces Round #753 (Div. 3) A-E

    打的烂的一批. 目录 A. Linear Keyboard[简单 /模拟] B. Odd Grasshopper[简单 / 找规律] C. Minimum Extraction[一般 / 排序 思维] ...

  2. Codeforces Round #528 (Div. 2) - D. Minimum Diameter Tree

    AC 在树的边缘上分配权值,使得树上最大路径权值和最小. 因为是在树的边缘上分配权值,所有所有的中间节点(非叶子节点)的权值为0,这样树上任意两点的距离最大就是一条包含两个边缘节点的路径. 统计所有边 ...

  3. Codeforces Round #753 (Div. 3)E. Robot on the Board 1

    问题翻译: The robot is located on a checkered rectangular(直角 的) board of size n×m (n rows, m columns). T ...

  4. Codeforces Round #700 (Div. 1Div. 2)

    Codeforces Round #700 (Div. 1&&Div. 2) 题号 题目 知识点 A Yet Another String Game 签到 B The Great He ...

  5. Codeforces Round #277 (Div. 2) 题解

    Codeforces Round #277 (Div. 2) A. Calculating Function time limit per test 1 second memory limit per ...

  6. Codeforces Round #700 (Div. 2)A~D2解题报告

    Codeforces Round #700 (Div. 2)A~D2解题报告 A Yet Another String Game 原题链接 http://codeforces.com/contest/ ...

  7. Codeforces Round #620 (Div. 2)(D. Shortest and Longest LIS)(O(n log n)的最长上升子序列或者贪心)

    Codeforces Round #620 (Div. 2)(D. Shortest and Longest LIS)(O(n log n)的最长上升子序列或者贪心) time limit per t ...

  8. Codeforces Round #644 (Div. 3) D.Buying Shovels

    Codeforces Round #644 (Div. 3) D.Buying Shovels 题目链接 Polycarp wants to buy exactly n shovels. The sh ...

  9. Codeforces Round #633 (Div. 2) C.Powered Addition

    Codeforces Round #633 (Div. 2) C.Powered Addition 题目链接 You have an array a of length n. For every po ...

最新文章

  1. POJ - 3160 Father Christmas flymouse tanjar缩点构图+dfs
  2. 科普:进入内核态究竟是什么意思?
  3. 《AR与VR开发实战》——2.7 3D物体识别
  4. 老版本fortran语言 内存无效_编程语言的分类
  5. [js] XML与JSON有什么的区别?
  6. 工作实践 之 Google Guava 工具集的使用 ,提高效率
  7. UINavigationBar的系统渲染方式
  8. eos java是什么框架_EOS的整体框架
  9. Sharepoint 自定义搜索
  10. java中的==和equals的区别
  11. Mysql 日志管理详解
  12. Charles添加断点拦截请求 修改request或者修改response
  13. php手机网页_使用PHPCMS搭建wap手机网站
  14. 电脑隐藏文件夹如何把它显示出来
  15. python_使用需要的气象台站提取气象数据
  16. linux dx游戏,10大免费 Linux 游戏
  17. java ftp上传失败_java ftp上传失败怎么办
  18. 裸辞指的是什么?裸辞到底好不好?
  19. 麦吉尔 计算机科学学分,麦吉尔大学计算机
  20. 计算机cpu intel,Intel的CPU后面带F是什么意思?

热门文章

  1. ASP.NET MVC 2 正式版发布了的
  2. C语言程序设计练习题解
  3. UVa10006 Carmichael Numbers【素数判定+快速模幂】
  4. 冷知识 —— 计算机科学及编程
  5. 英语词汇辨异 —— 形近字、近义词
  6. windows 用户管理
  7. 矩阵等式 matrix identity(二)
  8. Android多线程基础知识详解(傻瓜教程)
  9. python基础编程语法-Python编程入门——基础语法详解(经典)
  10. python新手入门代码-Python的初学者你现在可以自己quot;看”到代码的运行了!