HDU OJ Max sum 题目1003
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
for(int i=0;i<t;i++)
{
int n;
scanf("%d",&n);
int sum=0,max=-99999;
int curhead=1,rear=1,head=1;
for(int j=0;j<n;j++)
{
int temp;
scanf("%d",&temp);
if(sum<0)//小于零 说明開始加的是负数
{
curhead=j+1;//又一次计算开头元素的位置
sum=temp;
}else//假设大于等于0 就加上temp
{
sum+=temp;
}
if(sum>max)//假设sum超过max 又一次记录max 计算结尾元素的位置
{
rear=j+1;
head=curhead;
max=sum;
}
}
printf("Case %d:\n",i+1);
printf("%d %d %d\n",max,head,rear);
if(i!=t-1) printf("\n");
}
}
HDU OJ Max sum 题目1003的更多相关文章
- HDU 1024 Max Sum Plus Plus --- dp+滚动数组
HDU 1024 题目大意:给定m和n以及n个数,求n个数的m个连续子系列的最大值,要求子序列不想交. 解题思路:<1>动态规划,定义状态dp[i][j]表示序列前j个数的i段子序列的值, ...
- hdu 3415 Max Sum of Max-K-sub-sequence(单调队列)
题目链接:hdu 3415 Max Sum of Max-K-sub-sequence 题意: 给你一串形成环的数,让你找一段长度不大于k的子段使得和最大. 题解: 我们先把头和尾拼起来,令前i个数的 ...
- HDU 1024 Max Sum Plus Plus (动态规划)
HDU 1024 Max Sum Plus Plus (动态规划) Description Now I think you have got an AC in Ignatius.L's "M ...
- HDU 1244 Max Sum Plus Plus Plus
虽然这道题看起来和 HDU 1024 Max Sum Plus Plus 看起来很像,可是感觉这道题比1024要简单一些 前面WA了几次,因为我开始把dp[22][maxn]写成dp[maxn][2 ...
- HDU 1024 Max Sum Plus Plus【动态规划求最大M子段和详解 】
Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- hdu 1024 Max Sum Plus Plus DP
Max Sum Plus Plus Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php ...
- HDU 1024 max sum plus
A - Max Sum Plus Plus Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I6 ...
- hdu 3415 Max Sum of Max-K-sub-sequence 单调队列。
Max Sum of Max-K-sub-sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- HDU 1024 Max Sum Plus Plus(m个子段的最大子段和)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1024 Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/ ...
随机推荐
- axios 里面 then 默认写的function里面没有this,改成箭头函数后就可以用this了
,methods:{ loadJson:function(){ //this.jsonTest = "jjj" this.$http.get('http://localhost:3 ...
- Mysql 访问远程数据库,报错:1130-host ... is not allowed to connect to this MySql server 开放mysql远程连接 不使用localhost
参考:http://www.cnblogs.com/xyzdw/archive/2011/08/11/2135227.html 解决方法: 1. 改表法. 可能是你的帐号不允许从远程登陆,只能在loc ...
- Vickers Vane Pump Tips - Vane Pump Maintenance Note
The Vickers Vane Pump describes the matters needing attention in the maintenance of the vane p ...
- Android典型界面设计-访网易新闻实现双导航tab切换
一.问题描述 双导航tab切换(底部区块+区域内头部导航),实现方案底部区域使用FragmentTabHost+Fragment, 区域内头部导航使用ViewPager+Fragment,可在之前博客 ...
- sqlserver生成脚本
1.只生成数据 2.只生成架构 3.生成数据和架构
- 制作iso镜像U盘自动化安装linux系统
自制光盘引导自动化安装 首先我们要明白都需要哪些文件,我们列举下 ①需要一个文件夹来存放文件,将来把这个目录打包成iso ②准备kickstart文件(ks.cfg) ③准备启动文件启动菜单 差不多也 ...
- HTML5新增的主体元素article、section、nav、aside、time元素和pubdate属性
article artticle元素代表文档.页面或应用程序中独立的.完整的.可以独自被外部引用的内容.它可以是一篇博客或者报刊中的文章,一篇论坛帖子,一段用户评论或者独立的插件或其他任何独立的内容. ...
- k fit in Park Model
software: Gnuplot input: area_averaged_axial_mean_velocity_TI_1.txt # One Rotor, front, eldad blade ...
- POJ 3258 River Hopscotch (二分法)
Description Every year the cows hold an event featuring a peculiar version of hopscotch that involve ...
- 命令行可以执行python脚本,jenkins里执行报错:cannot find Chrome binary
“selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary”这个 ...