[topcoder]TallPeople
水题。http://community.topcoder.com/stat?c=problem_statement&pm=2923&rd=5854
一开始错了是因为理解错题意。还有就是初始化min应该设为Integer.MAX_VALUE,而不是相反。
public class TallPeople {
public int[] getPeople(String[] people) {
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
int len1 = people.length;
if (len1 == 0) return null;
String[] hgts = people[0].split(" ");
int len2 = hgts.length;
if (len2 == 0) return null;
int mx[][] = new int[len1][len2];
for (int i = 0; i < len1; i++) {
String line = people[i];
String[] heights = line.split(" ");
int _min = Integer.MAX_VALUE;
for (int j = 0; j < len2; j++) {
int tmp = Integer.parseInt(heights[j]);
mx[i][j] = tmp;
if (tmp < _min) _min = tmp;
}
if (_min > max) max = _min;
}
for (int j = 0; j < len2; j++) {
int _max = Integer.MIN_VALUE;
for (int i = 0; i < len1; i++) {
if (mx[i][j] > _max) _max = mx[i][j];
}
if (_max < min) min = _max;
}
return new int[] {max, min};
}
}
[topcoder]TallPeople的更多相关文章
- TopCoder kawigiEdit插件配置
kawigiEdit插件可以提高 TopCoder编译,提交效率,可以管理保存每次SRM的代码. kawigiEdit下载地址:http://code.google.com/p/kawigiedit/ ...
- 记第一次TopCoder, 练习SRM 583 div2 250
今天第一次做topcoder,没有比赛,所以找的最新一期的SRM练习,做了第一道题. 题目大意是说 给一个数字字符串,任意交换两位,使数字变为最小,不能有前导0. 看到题目以后,先想到的找规律,发现要 ...
- TopCoder比赛总结表
TopCoder 250 500 ...
- Topcoder几例C++字符串应用
本文写于9月初,是利用Topcoder准备应聘时的机试环节临时补习的C++的一部分内容.签约之后,没有再进行练习,此文暂告一段落. 换句话说,就是本文太监了,一直做草稿看着别扭,删掉又觉得可惜,索性发 ...
- TopCoder
在TopCoder下载好luncher,网址:https://www.topcoder.com/community/competitive%20programming/ 选择launch web ar ...
- TopCoder SRM 596 DIV 1 250
body { font-family: Monospaced; font-size: 12pt } pre { font-family: Monospaced; font-size: 12pt } P ...
- 求拓扑排序的数量,例题 topcoder srm 654 div2 500
周赛时遇到的一道比较有意思的题目: Problem Statement There are N rooms in Maki's new house. The rooms are number ...
- TopCoder SRM 590
第一次做TC,不太习惯,各种调试,只做了一题...... Problem Statement Fox Ciel is going to play Gomoku with her friend ...
- Topcoder Arena插件配置和训练指南
一. Arena插件配置 1. 下载Arena 指针:http://community.topcoder.com/tc?module=MyHome 左边Competitions->Algorit ...
随机推荐
- hibernate--could not initialize proxy - no Session--懒加载问题
今天在学习hibernate时,出现了以下错误: 错误分析: 如果我们取单个对象可以用get方法没有问题:但是如果我们取的的对象还有关联对象时用get就有问题,因为它不会把关联的对象取出来 参考博客: ...
- NetMQ(ZeroMQ)Client => Server => Client 模式的实现
ØMQ (也拼写作ZeroMQ,0MQ或ZMQ)是一个为可伸缩的分布式或并发应用程序设计的高性能异步消息库.它提供一个消息队列, 但是与面向消息的中间件不同,ZeroMQ的运行不需要专门的消息代理(m ...
- Linux下chkconfig命令详解即添加服务以及两种方式启动关闭系统服务
The command chkconfig is no longer available in Ubuntu.The equivalent command to chkconfig is update ...
- 牛客OJ——[编程题]A+B和C__如何输入多组测试数据(测试OK)
几个要注意的地方: (1)Java OJ,必须将类名写成Main (2)关于如何输入多组测试数据,用二维数组去存储是一个方法,直接在while里面做也可以 但是如果 (3)关于整形 ...
- ###STL学习--适配器
点击查看Evernote原文. #@author: gr #@date: 2014-08-24 #@email: forgerui@gmail.com STL中的适配器. ###stl学习 |--迭代 ...
- Java教程——int与Integer的区别
首先说一下int和Integer的区别: int 是基本数据类型,Integer是int的包装类.注意:后者的类型是"类".例如使用泛型,List<Integer> n ...
- Update msi using vbscript
参考: http://stackoverflow.com/questions/1609250/how-do-i-add-update-a-property-inside-an-msi-from-the ...
- mysql5.7的安装
1.在官网下载解压缩版 2.解压后配置默认文件 新建个my.ini(可以复制一份my-default.ini,并改名为my.ini).my.ini会替换掉下面的my-default.ini文件. 按需 ...
- crontab环境变量问题
今天设置linux定时任务时,python内调用的shell指令总执行失败,单独调用python脚本则无问题,考虑到是环境变量未生效引起. 故在执行crontab -e编辑配置文件时,将shell内执 ...
- 51nod1242 斐波那契数列 矩阵快速幂
1242 斐波那契数列的第N项 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 #include<stdio.h> #define mod 100000000 ...