Sum

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1706    Accepted Submission(s): 874

Problem Description
There is a number sequence A1,A2....An,you can select a interval [l,r] or not,all the numbers Ai(l≤i≤r) will become f(Ai).f(x)=(1890x+143)mod10007.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.(1≤n≤105)
Next line contains n integers A1,A2....An.(0≤Ai≤104)
It's guaranteed that ∑n≤106.
 
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
 
Source
 水题= =,有一种操作能把此数列中的某一段区间的数字全部变为f(xi),也可以不使用这个操作,求可获得的n个数的最大值。
我们不妨将f(xi)-xi处理出来表示变化值,从这个变化值数组中找到一段最大值就是能比SUMN(原始数列总和)最多增长多少,如果是一个负数按0处理表示不使用这个操作即可。好久没1A了尽管是水题还是>_<开森
 
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,M,i,j,k,t,a,b;
    while(cin>>N){int s=0,maxn=0,sumn=0;
        for(i=1;i<=N;++i){
            cin>>a;
            s+=a;
            b=(1890*a+143)%10007-a;
            sumn+=b;
            if(sumn>maxn) maxn=sumn;
            if(sumn<0) sumn=0;
        }
        cout<<s+maxn<<endl;
    }
    return 0;
}

HDU 5586 简单最大子段和变形的更多相关文章

  1. hdu 5586 Sum 最大子段和

    Sum Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5586 Desc ...

  2. HDU 3094 树上删边 NIM变形

    基本的树上删边游戏 写过很多遍了 /** @Date : 2017-10-13 18:19:37 * @FileName: HDU 3094 树上删边 NIM变形.cpp * @Platform: W ...

  3. HDU 1564 简单博弈 水

    n*n棋盘,初始左上角有一个石头,每次放只能在相邻的四个位置之一,不能操作者输. 如果以初始石头编号为1作为后手,那么对于每次先手胜的情况其最后一步的四周的编号必定是奇数,且此时编号为偶数,而对于一个 ...

  4. hdu 5586 Sum【dp最大子段和】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5586 Sum Time Limit: 2000/1000 MS (Java/Others)    Me ...

  5. HDU 5586 (dp 思想)

    Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submis ...

  6. hdu 2037简单贪心--活动安排问题

    活动安排问题就是要在所给的活动集合中选出最大的相容活动子集合,是可以用贪心算法有效求解的很好例子.该问题要求高效地安排一系列争用某一公共资源的活动.贪心算法提供了一个简单.漂亮的方法使得尽可能多的活动 ...

  7. HDU 2089 简单数位dp

    1.HDU 2089  不要62    简单数位dp 2.总结:看了题解才敲出来的,还是好弱.. #include<iostream> #include<cstring> #i ...

  8. HDU 1087 简单dp,求递增子序列使和最大

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  9. hdu 1237 简单计算器

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1237 简单计算器 Description 读入一个只包含 +, -, *, / 的非负整数计算表达式, ...

随机推荐

  1. Oracle HA 之ADVM和ACFS

    --ADVM ADVM主要是为了使除了数据库之外的第三方应用程序也可以使用asm存储,这样不限于使asm局限于自家的数据库领域.要想使用ADVM首先必须安装grid,已经创建好了asm磁盘,asm磁盘 ...

  2. make linux test main attempt to index a nil value

    Lua: getting started http://www.lua.org/start.html#learning Building from source Lua is very easy to ...

  3. backend community-driven web framework

    kataras/iris: The fastest backend community-driven web framework on (THIS) Earth. HTTP/2, MVC and mo ...

  4. Mirror--镜像相关错误

    场景: 同一局域网下搭建了镜像的服务器上报以下错误日志: An error occurred in a Service Broker/Database Mirroring transport conn ...

  5. mysql 数据操作 单表查询 where约束 工作模式

    select name,age from employee where id >7; 1.首先先找到表   from employee 2.表存在 mysql拿着约束条件  去表里 看依次匹配数 ...

  6. 字王·国标二级字库汉字GB内码un码三合一对照表2016版

    国标二级字库汉字GB内码un码三合一对照表 字王2016版 汉字内码表,是制作字库的基础,简单.便利的版本很少,根据实战经验,特此制作这个三合一版本的汉字.GB内码.Unicode码对照表: l 提供 ...

  7. hdu5188 01 背包

    这题说的是给了n道题每道题用时ti分钟,需要在Li 时间或者之后完成,得分为vi, 我们 首先必须要能过完成,尽量让L-t小的放在前面. 然后采用背包去做 #include <iostream& ...

  8. validform校验框架不显示错误提示

    今天做前端的校验,发现validform这个框架在项目中有,于是就网上搜索一下,开始使用,网上说,嗯,只写一句代码就可以用啦 $("#itemForm").Validform(); ...

  9. Python3:pyecharts数据可视化插件

    Python3:pyecharts数据可视化插件 一.简介 pyecharts 是一个用于生成 Echarts 图表的类库. Echarts 是百度开源的一个数据可视化 JS 库.主要用于数据可视化. ...

  10. phpstorm 代码片段使用方法

    原文链接: http://wwwquan.com/show-66-121-1.html 4.Live Templates代码片断 A)我们先介绍一个代码片段最基本的功能,我们要实现的目标是在html文 ...