HDOJ 2071 Max Num
Problem Description
There are some students in a class, Can you help teacher find the highest student .
Input
There are some cases. The first line contains an integer t, indicate the cases; Each case have an integer n ( 1 ≤ n ≤ 100 ) , followed n students’ height.
Output
For each case output the highest height, the height to two decimal plases;
Sample Input
2
3 170.00 165.00 180.00
4 165.00 182.00 172.00 160.00
Sample Output
180.00
182.00
同一个代码!这个运行时间正好是在超时的边界!~
import java.util.Scanner;
public class Main {
static Scanner sc=new Scanner(System.in);
public static void main(String[] args) {
int n=sc.nextInt();
while(n-->0){
int m=sc.nextInt();
double[] a=new double[m];
double max=a[0]=sc.nextDouble();
for(int i=1;i<a.length;i++){
a[i]=sc.nextDouble();
if(max<a[i]){
max=a[i];
}
}
System.out.printf("%.2f",max);
System.out.println();
}
}
}
HDOJ 2071 Max Num的更多相关文章
- HDU 2071 Max Num
http://acm.hdu.edu.cn/showproblem.php?pid=2071 Problem Description There are some students in a clas ...
- JSU省赛队员选拔赛个人赛1(Coin Change、Fibbonacci Number、Max Num、单词数、无限的路、叠筐)
JSU省赛队员选拔赛个人赛1 一.题目概述: A.Coin Change(暴力求解.动态规划) B.Fibbonacci Number(递推求解) C.Max Num(排序.比较) D.单词数 ...
- HDOJ 3415 Max Sum of Max-K-sub-sequence(单调队列)
因为是circle sequence,可以在序列最后+序列前n项(或前k项);利用前缀和思想,预处理出前i个数的和为sum[i],则i~j的和就为sum[j]-sum[i-1],对于每个j,取最小的s ...
- 最大子序列和 HDOJ 1003 Max Sum
题目传送门 题意:求MCS(最大连续子序列和)及两个端点分析:第一种办法:dp[i] = max (dp[i-1] + a[i], a[i]) 可以不开数组,用一个sum表示前i个数字的MCS,其实是 ...
- HDOJ 1024 Max Sum Plus Plus -- 动态规划
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1024 Problem Description Now I think you have got an ...
- HDOJ(1003) Max Sum
写的第一个版本,使用穷举(暴力)的方法,时间复杂度是O(N^2),执行时间超过限制,代码如下: #include <stdio.h> #define MAX_LEN 100000UL in ...
- Hdoj 1003.Max Sum 题解
Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum ...
- Max Num
Problem Description There are some students in a class, Can you help teacher find the highest studen ...
- [HDOJ] 2026.Max Sum
2026.Max Sum (c++) Problem Description Consider the aggregate An= { 1, 2, -, n }. For example, A1={1 ...
随机推荐
- try{}catch(){}//根据异常信息使用不同的方法要怎么实现
try{ }catch(Exception e){ if(e.getMessage().contains("123456798")) //使用e.getMessage().cont ...
- 数据库导出excel表数据
- 执行之前 (错误) 消息 错误 0xc0202009: 数据流任务 1: SSIS 错误代码 DTS_E_OLEDBERROR.出现 OLE DB 错误.错误代码: 0x80040E37. (S ...
- JS中escape 方法和C#中的对应
在项目中遇到js中escape过的json字符串,需要在C#中对应模拟编码,记得原来遇到过这个问题,但是当时没记录下来方案, 于是又搜索了一番,发现别人说的都是HttpUtility.UrlEncod ...
- C++中new的用法
new int;//开辟一个存放整数的存储空间,返回一个指向该存储空间的地址(即指针) new int(100);//开辟一个存放整数的空间,并指定该整数的初值为100,返回一个指向该存储空间的地址 ...
- php中文乱码
一. 首先是PHP网页的编码 1. php文件本身的编码与网页的编码应匹配 a. 如果欲使用gb2312编码,那么php要输出头:header(“Content-Typ ...
- 关于CenttOS的防火墙问题
Fix “Unit iptables.service failed to load: No such file or directory” Error In CentOS7 最近在升级CentOS7遇 ...
- Java compile时,提示 DeadCode的原因
在工程编译时,编译器发现部分代码是无用代码,则会提示:某一行代码是DeadCode.今天compile工程的时候发现某一个循环出现这个问题,如下: public void mouseOver(fina ...
- js四舍五入的bug和方法
简单来说js使用原生toFixed(x)截取小数的时候会有误差,出现在比如var o = 0.3303;o.toFixed(3);//0.330 toFixed(x)本来也是一个获取四舍五入的截取方法 ...
- 数据库,inner join,left join right join 的区别
假设有两个表: 学生和课程 student: class: id student id class studentId 1 ...
- python中归并排序
# coding=UTF-8 #!/usr/bin/python import sys def merge(nums, first, middle, last): "merge" ...