文件名称:4
-
所属分类:
- 标签属性:
- 上传时间:2016-11-20
-
文件大小:640byte
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
本题关于排序与细节处理,故选择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
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.