最大子段和-Program A
最大子段和
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
Input
Output
Sample Input
Sample Output
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{ int i,j,kase=0,n,t,b,c,d,x,sum;
scanf("%d",&t);
while(t--)
{ scanf("%d",&n);
for(j=1;j<=n;j++)
{
scanf("%d",&x);
if(j==1)
{
sum=b=x;
i=c=d=1;
}
else
{
if(x>x+b)
{
b=x;
i=j;
}
else
b+=x;
}
if(b>sum)
{
sum=b;
c=i;
d=j;
}
}
printf("Case %d:\n",++kase);
printf("%d %d %d\n",sum,c,d);
if(t)
cout<<endl; }
return 0;
}
最大子段和-Program A的更多相关文章
- GSS1 spoj 1043 Can you answer these queries I 最大子段和
今天下午不知道要做什么,那就把gss系列的线段树刷一下吧. Can you answer these queries I 题目:给出一个数列,询问区间[l,r]的最大子段和 分析: 线段树简单区间操作 ...
- C语言程序设计100例之(13):最大子段和
例13 最大子段和 题目描述 给出一段序列,选出其中连续且非空的一段使得这段和最大.例如在序列2,-4,3,-1,2,-4,3中,最大的子段和为4,该子段为3,-1,2. 输入格式 第一 ...
- 最大子段和(c++)
// 最大子段和.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<iostream> using namesp ...
- [project euler] program 4
上一次接触 project euler 还是2011年的事情,做了前三道题,后来被第四题卡住了,前面几题的代码也没有保留下来. 今天试着暴力破解了一下,代码如下: (我大概是第 172,719 个解出 ...
- Solved: “Cannot execute a program. The command being executed was \roslyn\csc.exe”
When you publish your ASP.NET project to a hosting account such as GoDaddy, you may run into the iss ...
- 关于The C compiler "arm-none-eabi-gcc" is not able to compile a simple test program. 的错误自省...
在 GCC ARM Embedded https://launchpad.net/gcc-arm-embedded/ 上面下载了个arm-none-eabi-gcc 用cmake 编译时 #指定C交叉 ...
- c中使用gets() 提示warning: this program uses gets(), which is unsafe.
今天在C代码中使用gets()时提示“warning: this program uses gets(), which is unsafe.”,然后这个程序还能运行,无聊的我开始查阅资料,为啥gets ...
- Unable to load R3 module D:\Program Files\Oracle\VirtualBox/VBoxDD.DLL (VBoxDD): GetLastError=1790 (VERR_UNRESOLVED_ERROR).
Unable to load R3 module D:\Program Files\Oracle\VirtualBox/VBoxDD.DLL (VBoxDD): GetLastError=1790 ( ...
- Git for Windows - The Program can't start because libiconv2.dll is missing
今天在新装的win10 预览版上面,发现git不能启动了,提示信息主要是: The Program can't start because libiconv2.dll is missing 于是我在网 ...
随机推荐
- hdfs namenode -initializeSharedEdits 和 hdfs namenode -bootstrapStandby
hdfs namenode -initializeSharedEdits 将所有journal node的元文件的VERSION文件的参数修改成与namenode的元数据相同 hdfs namenod ...
- CTEX里的函数、符号及特殊字符
CTEX里的函数.符号及特殊字符 声调 语法 效果 语法 效果 语法 效果 \bar{a} \acute{a} \check{a} \grave{a} \tilde{a} \hat ...
- Redis常用的基本命令整理
SET key value [EX seconds] [PX milliseconds] [NX|XX] 设置缓存 K-V,如果 key 已经存在,则重写 EX seconds -- 设置过期时间, ...
- Lua 栈中元素的位置
Lua与C.C#等的交互是通过栈来实现的,每次插入元素都是放在栈顶(top),至于元素的index,可以使用正数和负数两种方式, 如取栈底开始至第index个元素 -index = gettop - ...
- eclipse导入git项目(转)
1.首先在github.com上申请一个账号2.Eclipse需要安装egit插件,在Eclipse中选择help->Marketplace,在search中输入egit,找到后安装即可 3.从 ...
- 5.5 Selenium2中的元素定位
WebDriver的更加面向对象的方式大大降低了Selenium的入门门槛,对Web元素的操作也非常之简单易学.实际项目用起来,工作量最大的部分就是你如何解析定位到你的目标项目页面中的各种元素.好比你 ...
- C#运算除法和求整
在C#与法中,“/”除后所得的值的类型,跟他的除数和被除数的类型有关.如: int a=4; int b=5 ...
- Hadoop运维操作
1. 处理hadoop的namenode宕机 处理措施: 进入hadoop的bin目录,重启namenode服务 操作命令: cd path/to/hadoop/bin ./hadoop-d ...
- 使用cnblogs.com的用户体验和提出来的建议
1.是否提供良好的体验给用户(同时提供价值)? 我是很久以前就有CN的账号了的,因为这个网站有很多有用的信息,和比较活跃的论坛.很多不懂的问题可以求助上面的大神.但是,我第一次登陆主页面的时候我是懵逼 ...
- arrow css
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...