hdu_1003_Max Sum
Max Sum
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 142281 Accepted Submission(s): 33104
#include<iostream>
using namespace std;
int main()
{
int t,len,m=,h,n,w,l,r,p,e,i;
cin>>t;h=t;
while(t--)
{
m++;
l=r=p=e=;
cin>>len;
int a[len];
for(i=;i<len;i++)
cin>>a[i];
n=a[],w=a[];l=;p=;
for(i=;i<len;i++)
{
if(a[i]>n+a[i]){
n=a[i];
l=i;
r=i;
}
else {
n=n+a[i];
r=i;
}
if(n>w){
w=n;
e=r;
p=l;
}
}
cout<<"Case "<<m<<":"<<endl<<w<<" "<<p+<<" "<<e+<<endl;
if(m!=h)cout<<endl;
}
return ;
}
hdu_1003_Max 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 ...
随机推荐
- Bzoj 2453: 维护队列 && Bzoj 2120: 数颜色 分块,bitset
2453: 维护队列 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 578 Solved: 247[Submit][Status][Discuss] ...
- 配置好maven后,设置tomcat:run运行程序
1.要在intellij idea使用maven,同样是先要配置maven的路径,不过intellij idea已经集成maven插件了,省去了安装的麻烦 2.创建maven web项目 点击fini ...
- Android中使EditText失去焦点,edittext禁止弹出键盘[转]
转自http://www.cnblogs.com/yejiurui/archive/2013/01/02/2841945.html 在我们的应用中,有时候一进入一个页面, EditText默认就会自动 ...
- PowerShell常用的.Net 、COM对象(New-Object、Assembly)、加载程序集
#新建随机数对象实例:$Ran = New-Object System.Random$Ran.NextDouble() 有时候,要使用的实例的类保存在独立的库文件中,PowerShell默认未加载,会 ...
- Centos安装成功mysql-5.5.37
摘自http://www.2cto.com/os/201404/296364.html(原文请关注) 这几天在centos下装mysql,这里记录一下安装的过程,方便以后查阅 Mysql5.5.37安 ...
- C语言中volatilekeyword的作用
一.前言 1.编译器优化介绍: 由于内存訪问速度远不及CPU处理速度,为提高机器总体性能,在硬件上引入硬件快速缓存Cache,加速对内存的訪问.另外在现代CPU中指令的运行并不一定严格依照顺序运行,没 ...
- COCOS2D-X 精灵创建随笔
CCSprite类中创建Sprite的方法都是静态的: static CCSprite* create ( ) 创建一个无图片显示的精灵,可随后用 setTexture 方法设置显示图片 stati ...
- mysql的优化措施,从sql优化做起
http://geeksblog.cc/2016/06/11/mysql-optimize/ 优化sql的一般步骤 通过show status了解各种sql的执行频率 定位执行效率低的sql语句 通过 ...
- GO的跨平台数扰类型
基本数据类型的包装: 1.跨平台,用于移植 2.不同的框架类型包装的类型(MFC ,WIN32SDK,C) 3.基本数据类型的组装成的结构体 4.宏定义 数字类型 Go 也有基于架构的类型,例如:in ...
- 标准库function类型的使用
14.44编写一个简单的桌面计算器使其能处理二元运算. #include<iostream> #include<map> #include<functional> ...