javaHDU1003Max Sum
import java.util.Scanner;
public class Sum
{public static void main(String args[])
{Scanner cin=new Scanner(System.in);
int T,N,num,startp=1,endp=1;
T=cin.nextInt();
int m=T;
while(T-->0)
{int max=-1001,temp=1,sum=0;
N=cin.nextInt();
for(int i=1;i<=N;i++)
{num=cin.nextInt();
sum+=num;
if(sum>max)
{max=sum;
startp=temp;
endp=i;
}
if(sum<0)
{sum=0;
temp=i+1;
}
}
System.out.println("Case "+(m-T)+":");
System.out.println(max+" "+startp+ " "+endp);
if(T!=0)
{System.out.println();
}
}
}
}
javaHDU1003Max Sum的更多相关文章
- LeetCode - Two Sum
Two Sum 題目連結 官網題目說明: 解法: 從給定的一組值內找出第一組兩數相加剛好等於給定的目標值,暴力解很簡單(只會這樣= =),兩個迴圈,只要找到相加的值就跳出. /// <summa ...
- Leetcode 笔记 113 - Path Sum II
题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...
- Leetcode 笔记 112 - Path Sum
题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- BZOJ 3944 Sum
题目链接:Sum 嗯--不要在意--我发这篇博客只是为了保存一下杜教筛的板子的-- 你说你不会杜教筛?有一篇博客写的很好,看完应该就会了-- 这道题就是杜教筛板子题,也没什么好讲的-- 下面贴代码(不 ...
- [LeetCode] Path Sum III 二叉树的路径和之三
You are given a binary tree in which each node contains an integer value. Find the number of paths t ...
- [LeetCode] Partition Equal Subset Sum 相同子集和分割
Given a non-empty array containing only positive integers, find if the array can be partitioned into ...
- [LeetCode] Split Array Largest Sum 分割数组的最大值
Given an array which consists of non-negative integers and an integer m, you can split the array int ...
- [LeetCode] Sum of Left Leaves 左子叶之和
Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two l ...
随机推荐
- Android DownloadThread.run()学习
android系统的下载代码写的很好,考虑的比较全面,值得我们学习.DownloadThread是其中执行下载的部分,下面从run进行研究. run(){ 一上来会设置一下下载线程的优先级:THREA ...
- 正则 ?<= 和 ?= 用法
参考网址:http://baike.baidu.com/link?url=2zORJF9GOjU8AkmuHDLz9cyl9yiL68PdW3frayzLwWQhDvDEM51V_CcY_g1mZ7O ...
- 【HDOJ】1016 Prime Ring Problem
经典DP,写的可能麻烦了一些. #include <stdio.h> #define false 0 #define true 1 ]; ]; ]; void DFS(int, int, ...
- Sequence Assignments FRM-41830: List of Value contains no entries.
SYMPTOMS ============================================================ GL > Setup > Financials ...
- Xcode6新建的工程没有Frameworks文件夹了?!原来是这样
http://stackoverflow.com/questions/24181062/default-frameworks-missing-in-xcode-6-beta They are impo ...
- 注意!ASP.NET MVC 3 的一个 OutputCache 问题
在用 ASP.NET MVC 3 重写博客园网站首页时,特地留意了一下这个缓存问题,通过这篇博文分享一下. 在 ASP.NET MVC 3 中如果使用了 OutputCache,一定要在 Action ...
- Android Paint和Color类
要绘图,首先得调整画笔,待画笔调整好之后,再将图像绘制到画布上,这样才可以显示在手机屏幕上.Android 中的画笔是 Paint类,Paint 中包含了很多方法对其属性进行设置,主要方法如下: se ...
- [新]最近用unity5弄的一些渲染
Unity Separable Bokeh Depth-of-Field Hexagonal Blur Unity3d Realtime Dynamic Clouds Rendering hemisp ...
- 读《CSS禅意花园》 有感
1.图片用<img>标签添加到页面中,会增加页面的大小,导致页面加载需要更长的时间.可以用css background 引用图片. 1.1.若图像属于“内容”而不是“样式”的一部分,例如“ ...
- bss 概念
BSS段 在采用段式内存管理的架构中,BSS段(bss segment)通常是指用来存放程序中未初始化的全局变量的一块内存区域.BSS是英文Block Started by Symbol的简称.BSS ...