设为首页 加入收藏

TOP

Hdu 5586 sum【最大连续子序列和】
2016-04-27 17:24:59 】 浏览:702
Tags:Hdu 5586 sum 最大 连续 序列

SUM

Description

There is a number sequence \ \ \ \ \ \ \ \ \ \ \ ,you can select a interval [l,r] or not,all the numbers \ \ \ \ \ \ \ \ \ will become \ \ \ \ \ . \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ .After that,the sum of n numbers should be as much as possible.What is the maximum sum

Input

There are multiple test cases.
First line of each case contains a single integer n. \ \ \ \ \ \ \ \ \
Next line contains n integers \ \ \ \ \ \ \ \ \ \ \ . \ \ \ \ \ \ \ \ \ \
It's guaranteed that \ \ \ \ \ \ .

Output

For each test case,output the answer in a line.

Sample Input

 
 
2 10000 9999 5 1 9999 1 9999 1

Sample Output

 
  
19999 22033

题意:

给出一个序列,允许把其中某一连续段的所有值变成这个数对应的某个函数的值,只允许操作一次,问得到的最终序列的和最大为多少

题解:

找出一个数组,储存每一个数字经过函数运算后变成的数与原来这个数的差值,,对这个数组求最大连续子序列的和,然后加上原来数组的总和即为所求

比赛的时候确实脑残了,本来自己会的知识点,就稍微转化了一下,自己竟然没分析出来,真心怀疑人生了.....

学会的东西想要达到灵活运用,真的是好难啊..

/*
http://blog.csdn.net/liuke19950717
*/
#include
    
     
#include
     
       #include
      
        using namespace std; typedef long long ll; const ll maxn=1e5+5; const ll mod=10007; ll x[maxn],y[maxn]; ll max_sum(ll num[],ll n) { ll ans=0,tp=0; for(ll i=0;i
       
        

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇HDU-5668-Circle(中国余数定理/.. 下一篇用C语言讲一讲位运算 入门级(详..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目