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. poj2817WordStack(状压)

    链接 与上题类似  预处理一下各字符串之间最大的相同字符数就可以 注意dp要初始为负无穷 #include <iostream> #include<cstdio> #inclu ...

  2. 对XX证券报关于物联网操作系统的几个问题的答复

    XX证券报提问了几个关于物联网和物联网操作系统的问题,个人表达了一些粗陋的观点,在这里发表出来,与行业朋友交流和探讨. 物联网行业最需要解决的问题是什么? 虽然物联网这个行业被炒得比较热,但是截至目前 ...

  3. hadoop学习笔记——基础知识及安装

    1.核心 HDFS  分布式文件系统    主从结构,一个namenoe和多个datanode, 分别对应独立的物理机器 1) NameNode是主服务器,管理文件系统的命名空间和客户端对文件的访问操 ...

  4. CORREL

    CORREL Show All Returns the correlation coefficient of the array1 and array2 cell ranges. Use the co ...

  5. .net软件自动化测试笔记(API-1)

    .net 软件测试自动化之道 API(Application Programming Interface)包括单元测试(Unit Testing),模块测试(Module Testing),组件测试( ...

  6. 布隆过滤器(Bloom Filter)的原理和实现

    什么情况下需要布隆过滤器? 先来看几个比较常见的例子 字处理软件中,需要检查一个英语单词是否拼写正确 在 FBI,一个嫌疑人的名字是否已经在嫌疑名单上 在网络爬虫里,一个网址是否被访问过 yahoo, ...

  7. 【原】数据库SQL语句入门

    1.数据定义DDL(Data Definition Language)语言即对表结构的一些定义,主要包括动词为CREATE/DROP/ALTER. 1.1.CREATE语句 CREATE TABLE ...

  8. 洛谷P1117 棋盘游戏

    洛谷1117 棋盘游戏 题目描述 在一个4*4的棋盘上有8个黑棋和8个白棋,当且仅当两个格子有公共边,这两个格子上的棋是相邻的.移动棋子的规则是交换相邻两个棋子.现在给出一个初始棋盘和一个最终棋盘,要 ...

  9. SPI协议及其工作原理浅析

    转载自:http://bbs.chinaunix.net/thread-1916003-1-1.html一.概述. SPI, Serial Perripheral Interface, 串行外围设备接 ...

  10. shell脚本应用(3)--语法结构

    判断语句 条件判断 test expression [ expression ] 条件表达式中常用的判断 数值-eq -ne -gt -lt -ge -le[equal not greater tha ...