当前位置: 首页 > 编程日记 > 正文

HDOJ 1157 HDU 1157 Who's in the Middle ACM 1157 IN HDU

MiYu原创, 转帖请注明 : 转载自 ______________白白の屋  

题目地址:

http://acm.hdu.edu.cn/showproblem.php?pid=1157

题目描述:

Who's in the Middle

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2451    Accepted Submission(s): 1204


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.

水题,  直接代码 :

/*

MiYuÔ­´´, תÌûÇë×¢Ã÷ : ×ªÔØ×Ô ______________°×°×¤ÎÎÝ

http://www.cnblog.com/MiYu

Author By : MiYu

Test      : 1

Program   : 1157

*/


#include <iostream>

#include <algorithm>

using namespace std;

int cow[10010];

int main ()

{

int N;

while ( cin >> N ){

for ( int i = 0; i < N; ++ i ) cin >> cow[i];

sort ( cow, cow + N );

cout << cow[N/2] << endl;

}

return 0;

}


转载于:https://www.cnblogs.com/MiYu/archive/2010/09/04/1818237.html

相关文章:

Keras使用多个GPU并行

model Model(inputs[v_i, v_j], outputsoutput_list) model multi_gpu_model(model,4) model.compile(....) 主要就是第二句话中的 multi_gpu_model函数&#xff0c;会把数据和模型分到多个gpu上执行有个坑&#xff0c;就是整个程序导入keras时要么全部from keras import ...…

使用JackJSON 流式API 创建JSON串【学习记录】

教程网址&#xff1a;Jackson流式API 目标JSON串 原始JSON串 核心代码 思路&#xff1a;先将原始JSON串生成对应的对象&#xff0c;获取到其数据 package com.run.runlpwebdemo.utils;import java.io.IOException; import java.io.StringWriter; import java.util.List;impo…

Eclipse插件安装

clispe想必大家都很熟悉了&#xff0c;一般来说&#xff0c;eclipse 插件都是安装在plugins目录 下。不过这样一来&#xff0c;当安装了许多插件之后&#xff0c;eclipse变的很大&#xff0c;最主要的是不便 于更新和管理众多插件。用links 方式安装eclipse插件&#xff0c;可以…

linux 命令之文件读取,head, tail, tailf, sed

head 看文件的前100行head -100 filename tail/tailf查看文件的后100行tail -100 filename 或 tail -n 100 filename tailf filename tail -f filename sed sed -n 100,200p filename 这样你就可以只查看文件的第100行到第200行。 转载于:https://www.cnblogs.com/xiaoniu-…

软件使用[19]

1 -- 服务自动的原理2 -- 命令chkconfig使用方法chkconfig是Linux系统中基于命令行的服务管理工具&#xff0c;其用途是启用和禁用系统服务。 chkconfig --list [name] chkconfig --add name chkconfig --del name chkconfig [--level levels] name chkconfig [--level le…

ORA-01747: user.table.column, table.column 或列说明无效 异常解决方法总结

1.sql 拼接错误 比如多了个逗号&#xff0c;少了个引号什么的&#xff0c;大部分其实都是这个问题&#xff0c;还是多细心&#xff0c;复制粘贴的时候多看看。 2.sql语句中使用了 Oracle 声明的关键字 --查询数据库关键字select * from v$reserved_words;----查询表中是否有关键…

SpringBoot 获取 application.properties 文件中的内容方法 【学习记录】

1 . Value注解来获取配置的值 2. ConfigurationProperties注解

安装swoole

php需要安装swoole扩展 swoole4.3.2 cd /usr/local/src/wget https://pecl.php.net/get/swoole-4.3.2.tgztar -zxvf swoole-4.3.2.tgzmv swoole-4.3.2 swoolecd swoole/usr/local/php/bin/phpize# 增加php配置./configure --enable-openssl --enable-swoole --enable-http2 --e…

layUI 学习记录

1 点击导航栏跳转页面 <!DOCTYPE html> <html> <head><meta charset"utf-8"><meta name"viewport" content"widthdevice-width, initial-scale1, maximum-scale1"><title>layout 后台大布局 - Layui</ti…

分享个网盘,个人觉得很不错!

金山网盘&#xff1a;http://k.wps.cn 可以在电脑上虚拟一个盘&#xff0c;你要上传下载删除文件&#xff0c;可以直接在本地电脑上操作&#xff0c;就像用自己硬盘的一个分区或是U盘一样&#xff0c;操作方便&#xff0c;但速度肯定没硬盘U盘快了&#xff0c;真正速度取决于你…

JSP 学习笔记 3

八jsp 九个内置对象1.内置对象的描述这就个内置对象都是servlet API的类或者接口的实例。JSP把他们都初始化了。2.九个内置对象分别是l application: javax.servlet.ServletContext的实例&#xff0c;代表JSP所属WEB应用本身&#xff0c;用于JSP叶面之间&#xff0c;或…

空间新闻模块CSS

#mod_10024 { /* 国内新闻模块 */ } #mod_10024 .modtl { /* 题头左 */ } #mod_10024 .modtc { /* 题头中 */ } #mod_10024 .modtr { /* 题头右 */ } #mod_10024 .modtit { /* 模块标题 */ } #mod_10024 a.modact img { /* "编辑图标" */ } #mod_10024 a.modact,#mod…

Cordova入门系列(三)Cordova插件调用

上一章我们介绍了cordova android项目是如何运行的&#xff0c;这一章我们介绍cordova的核心内容&#xff0c;插件的调用。演示一个例子&#xff0c;通过cordova插件&#xff0c;去调用摄像头。 一、插件的安装以及基本信息&#xff1a; 我们先在项目中安装调用摄像头的插件cor…

LVS 介绍 原理

一、 LVS简介 LVS是Linux Virtual Server的简称&#xff0c;也就是Linux虚拟服务器, 是一个由章文嵩博士发起的自由软件项目&#xff0c;它的官方站点是www.linuxvirtualserver.org&#xff08;版本很久不更新了&#xff09;。 现在LVS已经是 Linux标准内核的一部分…

腾讯云 短信服务 【学习记录 】

github 链接 https://github.com/qcloudsms/qcloudsms_java/tree/master maven 要使用 qcloudsms_java 功能&#xff0c;需要在 pom.xml 中添加如下依赖&#xff0c; <dependency><groupId>com.github.qcloudsms</groupId><artifactId>qcloudsms<…

Coolite Toolkit学习笔记六:常用控件Accordion、ToolBar、ToolTip

一、Accordion控件 Accordion的功能非常适用&#xff0c;使用很简单&#xff0c;轻轻松松的就可以构建一个可折叠的界面展示应用效果。相信大多数做ASP.NET开发的朋友都使用过ASP.NET AJAX Control Toolkit&#xff0c;它里面也提供有Accordion控件&#xff0c;详细可以查…

与ObjectDataSource共舞

4&#xff0c;ORM组件XCode&#xff08;与ObjectDataSource共舞&#xff09; XCode为了能更方便的解决大部分问题&#xff0c;不得不“屈身”于ObjectDataSource。 先上一个经典例子&#xff08;ObjectDataSourceGridView&#xff09;&#xff08;ObjectDataSource&#xff09;…

2.4 Go语言基础之切片

本文主要介绍Go语言中切片&#xff08;slice&#xff09;及它的基本使用。 一、引子 因为数组的长度是固定的并且数组长度属于类型的一部分&#xff0c;所以数组有很多的局限性。 例如&#xff1a; func arraySum(x [3]int) int{sum : 0for _, v : range x{sum sum v}return …

java 文件下载 【学习记录】

工具类 public static Boolean downloadExcelFile(HttpServletResponse response, String fileName) {OutputStream output;File file new File(fileName);if (file.exists()) {try {FileInputStream fileInputStream new FileInputStream(file);BufferedInputStream buffe…

[UI自动化]:控制浏览器操作

控制浏览器窗口大小 . PC端执行自动化测试脚本大多的情况下是希望浏览器在全屏幕模式下执行&#xff0c;那么可以使用maximize_window()方法使打开的浏览器全屏显示 控制浏览器后退、前进 在使用浏览器浏览网页时&#xff0c;浏览器提供了后退和前进按钮&#xff0c;可以方便地…

在项目中使用Google Closure Compiler

现在的Web项目总是离不开大量JavaScript&#xff0c;而JS文件的体积也越来越大&#xff0c;也越来越影响页面的感知性能&#xff08;Perceived Performance&#xff09;。因此&#xff0c;我们会对JS文件进行压缩&#xff0c;一方面是使用Gzip&#xff0c;而另一方面则是去除JS…

文件服务器共享目录设置(二)

三、 设置磁盘配额及文件屏蔽 为了防止用户无限制的上传文件&#xff0c;或上传病毒木马等文件&#xff0c;还需要进一步加强安全设置。用磁盘配额来管理用户的文件夹空间&#xff0c;用文件屏蔽来阻止用户上传有风险的文件。 在win2003中&#xff0c;磁盘配额只能…

Codeforces 894.D Ralph And His Tour in Binary Country

D. Ralph And His Tour in Binary Countrytime limit per test2.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputRalph is in the Binary Country. The Binary Country consists of n cities and (n - 1) bidirectional roads connect…

linux下获取系统时间 和 时间偏移

获取linux时间 并计算时间偏移 void getSystemTimer(void){#if 0 char *wdate[]{"Sun","Mon","Tue","Wed","Thu","Fri","Sat"} ; time_t timep; struct tm *p; time(&timep); pgmtime(&timep)…

使用git命令上传本地文件到GitHub上

1、官网下载git并且anz安装 2、在Github上申请账号 3、在本地使用git命令生成私钥和公钥 连续按三次 回车键 $ ssh-keygen -t rsa -C "账号"生成如图 将生成的公钥设置到github上 &#xff0c; 生成公钥的地址是 ./ssh &#xff08;C盘的用户目录&#xff09; 4…

POI解析Excel文件工具类

/*** 读取excel数据*/public static List<Map<String, Object>> exportListFromExcel(File file, int sheetNum) throws IOException { return exportListFromExcel(new FileInputStream(file), FilenameUtils.getExtension(file.getName()), sheetNum); } publ…

关于Bulk加载模式

Bulk加载模式是Informatica提供的一种高性能数据加载模式&#xff0c;它利用数据库底层机制&#xff0c;依靠调用数据库本身提供的Utility来进行数据的加载  该方式将绕过数据库的log记录&#xff0c;以此提高数据库加载性能&#xff0c;因此Bulk模式不能进行数据的Rollback操…

C#:CsvReader读取.CSV文件(转换成DataTable)

原文引用&#xff1a;https://www.codeproject.com/Articles/9258/A-Fast-CSV-Reader using LumenWorks.Framework.IO.Csv;using System;using System.Collections.Generic;using System.Data;using System.IO;using System.Linq;using System.Text;using System.Threading.Tas…

Standup Timer的MVC模式及项目结构分析

前言 学习android一段时间了&#xff0c;为了进一步了解android的应用是如何设计开发的&#xff0c;决定详细研究几个开源的android应用。从一些开源应用中吸收点东西&#xff0c;一边进行量的积累&#xff0c;一边探索android的学习研究方向。这里我首先选择了jwood的Standup …

ISDN的配置

ISDN的配置 1、 实验目的&#xff1a; 通过配置ISDN使两个路由器之间能够通信 2、 实验拓扑图&#xff1a; 3、 实验步骤&#xff1a; &#xff08;1&#xff09; R1的配置 Router> R1的ISDN配置 Router>en R…