Hdu 1157

杭电oj 1157 Who’s in the Middle

Problem Description

FJ is surveying his herd to find the most average cow. He wants to know how much milk this ‘median’ cow gives: half of the cows give as much or more than the median; half give as much or less.

Given an odd number of cows N (1 <= N < 10,000) and their milk output (1…1,000,000), find the median amount of milk given such that at least half the cows give the same amount of milk or more and at least half give the same or less.

Input

  • Line 1: A single integer N

  • Lines 2…N+1: Each line contains a single integer that is the milk output of one cow.

Output

  • Line 1: A single integer that is the median milk output.

Sample Input

5
2
4
1
3
5

Sample Output

3

Hint

INPUT DETAILS:

Five cows with milk outputs of 1…5

OUTPUT DETAILS:

1 and 2 are below 3; 4 and 5 are above 3.

Source

USACO 2004 November

Recommend

mcqsmall

#include"iostream"
#include<algorithm>
using namespace std;

bool cmp(int a, int b)
{
	return a > b;
}

int main()
{
	int N=0;
	int milk[10000] = { 0 };
	while (cin >> N && N)
	{
		for (int i = 0;i < N;i++)
		{
			cin >> milk[i];
		}
		sort(milk, milk + N, cmp);
		cout << milk[N / 2 ] << endl;
	}

    return 0;
}

第一次编辑,试试水。

### 如何在 MathType 中设置和格式公式编号 #### 设置公式编号的基础方法 为了实现公式的自定义编号,在MathType中可以通过特定选项来完成这一功能。当用户希望调整或设定公式编号时,应当进入MathType的“预置(P)”菜单下的子项“章节起始(C)...”,在此处能够指定编号的具体样式以及初始值[^1]。 #### 批量更改公式编号格式 对于已经编写好的文档内含有大量由MathType创建并带有默认编号的公式而言,若需统一改变这些编号的形式,则可利用软件内置的大规模更新机制。具体来说就是选中目标区域内的所有相关对象之后执行相应的命令来进行全局性的变更处理[^2]。 #### 自动按照章节顺序编号 为了让公式能依据所在位置所属的不同部分而获得连续且有序列号标记,应该事先规划好每一节的内容结构,并确保各章节之间存在清晰界定;接着针对每一段落里的首个出现之数学表达式实施特殊标注——即选择它作为该区段代表作之一,“插入下一章”的动作有助于触发系统识别新的分段起点从而正确分配后续条目上的索引标签[^3]。 ```python # Python伪代码展示逻辑流程而非实际可用语法 for chapter in document.chapters: first_formula = find_first_math_expression(chapter) apply_chapter_start_tag(first_formula) ``` #### 处理因外部工具影响而导致的问题 有时由于Word中的某些特性比如格式刷可能会影响到嵌入其中的MathType元素造成显示异常等情况发生。为了避免这种情况的发生,在大规模编辑之前最好先做好备份工作并将预期要应用到整个项目的样式提前准备好以便随时调用。另外值得注意的是关于跨引用产生的兼容性难题也可以通过合理配置域代码的方式来加以规避[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值