最大子段和-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 于是我在网 ...
随机推荐
- 数据存储之SQLite
SQLite是目前主流的嵌入式关系型数据库,其最主要的特点就是轻量级.跨平台,当前很多嵌入式操作系统都将其作为数据库首选.虽然SQLite是一款轻型数据库,但是其功能也绝不亚于很多大型关系数据库.学习 ...
- js倒计时 网上流传最多的
<!DOCTYPE html><html><head><script src="http://libs.baidu.com/jquery/1.10. ...
- js获取时间格式化
http://www.cnblogs.com/zhangpengshou/archive/2012/07/19/2599053.html
- js setTimeout 与 setInterval 以及 for 循环 刷新UI
1. setTimeout() 方法用于在指定的毫秒数后调用函数或计算表达式:执行一次: 如果需要执行多次,自身再次调用 setTimeout(): 示例:无穷循环并带停止按钮的 <html&g ...
- 不能使用tpcc-mysql测试OneProxy
因为Proxy类的中间件不适合实现prepared statement,所以无法测试,导致我们无法使用标准的测试工具去发布OneProxy的测试结果
- Django开发博客- 部署
安装Git Git是一个被大量程序员使用的”版本控制系统”.此软件可以跟踪任何时间文件的改变,这样你以后可以随时召回某个特定版本. windows系统下面可以下载git-scm安装.除了第5步”Adj ...
- 使用Visual Studio 2013进行单元测试--初级篇
1.打开VS2013 --> 新建一个项目.这里我们默认创建一个控制台项目.取名为UnitTestDemo 2.在解决方案里面新增一个单元测试项目.取名为UnitTestDemoTest 创建完 ...
- python 电影下载链接爬虫
V1.0 功能:从比较知名的几个电影下载网站爬取下载链接,并自动打印出来: 代码: # -*- coding: utf8 -*- from bs4 import BeautifulSoup impor ...
- Batman+joker乱谈
偶然一天内两次看到关于希斯·莱杰的文章(上面这个joker),貌似很多地方看到过这个,但是为什么他这么出名.知乎上的一篇文章 http://daily.zhihu.com/story/434137 ...
- Android客户端向服务器端发送数据的流程(1)
原理: android客户端通过使用org.apache.http.impl.client.DefaultHttpClient类来发送数据; 方法介绍: HttpClient是android中提供的一 ...