ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

2.10英文题面翻译

2022-02-10 20:35:01  阅读:223  来源: 互联网

标签:sequence 题面 32 median 英文 序列 sorted 排序 2.10


描述

Given a sequence of N nonnegative integers. Let's define the median of such sequence. If N is odd the median is the element with stands in the middle of the sequence after it is sorted. One may notice that in this case the median has position (N+1)/2 in sorted sequence if sequence elements are numbered starting with 1. If N is even then the median is the semi-sum of the two "middle" elements of sorted sequence. I.e. semi-sum of the elements in positions N/2 and (N/2)+1 of sorted sequence. But original sequence might be unsorted.

Your task is to write program to find the median of given sequence.

输入

The first line of input contains the only integer number N - the length of the sequence. Sequence itself follows in subsequent lines, one number in a line. The length of the sequence lies in the range from 1 to 250000. Each element of the sequence is a positive integer not greater than 2^32 - 1 inclusive.

输出

You should print the value of the median with exactly one digit after decimal point.

OpenJudge - 1625:Sequence Median

翻译

描述

给定一个N个非负整数序列。我们来定义这个序列的中值。如果N是奇数,则中位数是排序后位于序列中间的元素。人们可能会注意到,在这种情况下,如果序列元素从1开始编号,那么中值在排序序列中的位置是(N+1)/2。如果N是偶数,那么中值就是排序序列中两个“中间”元素的半和。即排序序列中位置N/2和(N/2)+1的元素的半和。但是原始序列可能是无序的。

你的任务是编写程序,找出给定序列的中位数。

输入

输入的第一行包含唯一的整数N——序列的长度。序列本身跟随其后的行,一行中的一个数字。该序列的长度范围是1 ~ 250000。序列的每个元素都是一个不大于2^32 - 1(含2^32 - 1)的正整数。

输出

你需要输出小数点后恰好有一位的中位数值。

标签:sequence,题面,32,median,英文,序列,sorted,排序,2.10
来源: https://blog.csdn.net/qq_64149314/article/details/122868563

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有