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的更多相关文章

  1. LeetCode - Two Sum

    Two Sum 題目連結 官網題目說明: 解法: 從給定的一組值內找出第一組兩數相加剛好等於給定的目標值,暴力解很簡單(只會這樣= =),兩個迴圈,只要找到相加的值就跳出. /// <summa ...

  2. 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 ...

  3. Leetcode 笔记 112 - Path Sum

    题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...

  4. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  5. BZOJ 3944 Sum

    题目链接:Sum 嗯--不要在意--我发这篇博客只是为了保存一下杜教筛的板子的-- 你说你不会杜教筛?有一篇博客写的很好,看完应该就会了-- 这道题就是杜教筛板子题,也没什么好讲的-- 下面贴代码(不 ...

  6. [LeetCode] Path Sum III 二叉树的路径和之三

    You are given a binary tree in which each node contains an integer value. Find the number of paths t ...

  7. [LeetCode] Partition Equal Subset Sum 相同子集和分割

    Given a non-empty array containing only positive integers, find if the array can be partitioned into ...

  8. [LeetCode] Split Array Largest Sum 分割数组的最大值

    Given an array which consists of non-negative integers and an integer m, you can split the array int ...

  9. [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 ...

随机推荐

  1. 正则表达式(javascript)学习总结

    正则表达式在jquery.linux等随处可见,已经无孔不入.因此有必要对这个工具认真的学习一番.本着认真.严谨的态度,这次总结我花了近一个月的时间.但本文无任何创新之处,属一般性学习总结. 一.思考 ...

  2. netsh命令

    C:\Windows\System32>netsh interface ipv6 show address level=verbose 地址 ::1 参数-------------------- ...

  3. 微软公有云事件中心(Azure Event Hubs)在开放物联网大会(OIOT)啼声初试

     发布于 2014-12-29 作者 刘 天栋 2014年12月18日,InfoQ在京召开开放物联网大会(Open IOT Conference),微软开放技术(中国)资深项目经理陈岭在大会中针对 ...

  4. 【转】iTunes下载速度太慢?两招帮你提速!-- 不错

    原文网址:http://bbs.app111.com/thread-275-1-1.html 不用说,很多朋友都发现在大陆,下载 iTunes 上的东西实在是慢如蜗牛,小一点的软件还能坚持一下,大一点 ...

  5. jquery的小插件(按钮抖动)——衍生QQ窗口抖动

    1.抖动的按钮 效果预览:http://runjs.cn/detail/tyx8dbag <script type="text/javascript"> //shake ...

  6. LightOJ 1220 Mysterious Bacteria 水题

    暴力就行了,找出素因子,正的最多是30,然后负的最多是31(这一点wa了一次) #include <cstdio> #include <iostream> #include & ...

  7. POJ 3169 Layout 差分约束系统

    介绍下差分约束系统:就是多个2未知数不等式形如(a-b<=k)的形式 问你有没有解,或者求两个未知数的最大差或者最小差 转化为最短路(或最长路) 1:求最小差的时候,不等式转化为b-a>= ...

  8. Visual Studio 2010打开水晶报表是出现二进制

    水晶报表在64位的机器下未安装成功 解决方法 到http://www.cnblogs.com/siyunianhua/p/4806513.html下载  水晶报表VS2010版IDE安装标准版SAP ...

  9. 都说ConcurrentDictionary<TKey, TValue>有陷阱

    看这么几句解释(英文原帖): private static void ConcurrentDictionary() { var dict = new ConcurrentDictionary<i ...

  10. Video Surveillance - POJ 1474(判断是否存在内核)

    题目大意:询问是否在家里装一个监视器就可以监控所有的角落. 分析:赤裸裸的判断多边形内核题目. 代码如下: #include<iostream> #include<string.h& ...