文件名称:4
介绍说明--下载内容均来自于网络,请自行研究使用
本题关于排序与细节处理,故选择int数组作为数据结构。
算法思想如下:对于输入的数据,根据其后的‘+’‘-’,用a,b的数组分别记录染病和正常的动物的高度。然后分别将a,b两数组排序。对于其后的m组询问,分别求出要杀中的动物数量x和最多误杀的动物数量y,分别询问a,b数组的倒数x,y位置的元素,稍作处理,分别作为最高高度和最低高度输出(若不和逻辑,输出-1)。程序结束。
复杂度:本题的运算时间主要用于排序(快排),故复杂度为O(nlogn)。空间复杂度是 O(n)。
-This question on the sort and details of the deal, it is selected int array as a data structure.
Algorithm for the following ideas: For the input data, according to the subsequent + - , with a, b, respectively, the array of infected and normal animal height. Then a, b, respectively, the two array sort. For the subsequent group m queries, respectively, to determine the number of animals to kill x and the number of animals manslaughter y, were asked a, b array of reciprocal x, y position of the element, a little processing, respectively, as the maximum height and The minimum height output (if not and logic, outputs-1). The program ends.
Complexity: The computation time of this problem is mainly used for sorting (fast row), so the complexity is O (nlogn). The spatial complexity is O (n).
算法思想如下:对于输入的数据,根据其后的‘+’‘-’,用a,b的数组分别记录染病和正常的动物的高度。然后分别将a,b两数组排序。对于其后的m组询问,分别求出要杀中的动物数量x和最多误杀的动物数量y,分别询问a,b数组的倒数x,y位置的元素,稍作处理,分别作为最高高度和最低高度输出(若不和逻辑,输出-1)。程序结束。
复杂度:本题的运算时间主要用于排序(快排),故复杂度为O(nlogn)。空间复杂度是 O(n)。
-This question on the sort and details of the deal, it is selected int array as a data structure.
Algorithm for the following ideas: For the input data, according to the subsequent + - , with a, b, respectively, the array of infected and normal animal height. Then a, b, respectively, the two array sort. For the subsequent group m queries, respectively, to determine the number of animals to kill x and the number of animals manslaughter y, were asked a, b array of reciprocal x, y position of the element, a little processing, respectively, as the maximum height and The minimum height output (if not and logic, outputs-1). The program ends.
Complexity: The computation time of this problem is mainly used for sorting (fast row), so the complexity is O (nlogn). The spatial complexity is O (n).
(系统自动生成,下载前可以参看下载内容)
下载文件列表
4.cpp