题目大意:现在有一个数列,还有一个数字x,你可以将这个数列中的一段连续子序列同时乘以这个数字x(当然也可以不乘),然后问你最大子段和是多少

做法:dp,你懂的

#include<iostream>
#include<cstdio>
using namespace std;
long long dp[],x,ans;
int n;
int main(){
scanf("%d",&n);
cin>>x;
long long a;
for(int i=;i<=n;i++){
cin>>a;
dp[]=max(0LL,dp[]+a);
dp[]=max(dp[],dp[]+x*a);
dp[]=max(dp[],dp[]+a);
ans=max(ans,dp[]);
}
cout<<ans<<endl;
return ;
}

CF-1155 D.Beautiful Array的更多相关文章

  1. Codeforces 1155 D Beautiful Array DP,最大子段和

    题意 给出一个长度为\(n\)的数列和数字\(x\),经过最多一次操作将数列的一个子段的每个元素变为\(a[i]*x\),使该数列的最大子段和最大 分析 将这个数列分为3段考虑,第一段和第三段是未修改 ...

  2. [Swift]LeetCode932. 漂亮数组 | Beautiful Array

    For some fixed N, an array A is beautiful if it is a permutation of the integers 1, 2, ..., N, such ...

  3. 漂亮数组 Beautiful Array

    2019-04-06 16:09:56 问题描述: 问题求解: 本题还是挺有难度的,主要是要考虑好如何去进行构造. 首先考虑到2 * A[i] = A[j] + A[k],那么j,k就必须是同奇同偶, ...

  4. LeetCode - Beautiful Array

    For some fixed N, an array A is beautiful if it is a permutation of the integers 1, 2, ..., N, such ...

  5. Educational Codeforces Round 63 D. Beautiful Array

    D. Beautiful Array time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. 932. Beautiful Array

    For some fixed N, an array A is beautiful if it is a permutation of the integers 1, 2, ..., N, such ...

  7. 北邮校赛 I. Beautiful Array(DP)

    I. Beautiful Array 2017- BUPT Collegiate Programming Contest - sync 时间限制 1000 ms 内存限制 65536 KB 题目描述 ...

  8. [Educational Codeforces Round 63 ] D. Beautiful Array (思维+DP)

    Educational Codeforces Round 63 (Rated for Div. 2) D. Beautiful Array time limit per test 2 seconds ...

  9. LC 932. Beautiful Array

    For some fixed N, an array A is beautiful if it is a permutation of the integers 1, 2, ..., N, such ...

  10. [LeetCode] 932. Beautiful Array 漂亮数组

    For some fixed N, an array A is beautiful if it is a permutation of the integers 1, 2, ..., N, such ...

随机推荐

  1. NopCommerce 4.2的安装与运行

    一.关于NopCommerce NopCommerce是国外ASP.Net领域一个高质量的B2C开源电商项目,最新版本4.2基于ASP.NET Core MVC 2.2和EF Core 2.2开发,其 ...

  2. python--8大排序(原理+代码)

    常用的排序方法:冒泡排序.选择排序.插入排序.快速排序.堆排序.归并排序 冒泡排序(Bubble Sort): 比较相邻的元素.如果第一个比第二个大(升序),就交换他们两个. 对每一对相邻元素作同样的 ...

  3. Protractor - 怎样运行

    前一篇设置好了Protractor基本运行环境,那怎样运行Protractor呢? 要运行我们的测试脚本,至少需要配置好两个文件: ---Package.json ---conf.js Package ...

  4. docker安装完报错:Failed to start docker.service: Unit docker.service is masked

    执行 systemctl start docker 报错 Failed to start docker.service: Unit docker.service is masked. 解决 syste ...

  5. C# 获取系统硬件可用信息

    如何获取系统可用磁盘和可用内存? 1 获取磁盘信息 这个有自带的 DriveInfo 可以用. DriveInfo 类 (System.IO) | Microsoft Docs 2 获取内存信息 参考 ...

  6. linux tmux用法

    1. 安装工具 Centos : yum install tmux 2. 基本操作 新建会话:tmux new -s session-name 查看会话:tmux ls 进入会话:tmux a -t  ...

  7. 1.java容器基本内容

    目录 java容器概述 1.collection接口 (1)collection接口方法 (2)set接口实现类 (3)list接口实现类 (4)queue接口实现类 2.map接口 java容器概述 ...

  8. /etc/profile和~/.bash_profile等文件的区别和联系

    对比说明:/etc/profile:为系统的每个用户设置环境信息和启动程序,当用户第一次登录时,该文件被执行,其配置对所有登录的用户都有效.当被修改时,必须重启才会生效.英文描述:”System wi ...

  9. Asp.net MVC 中的TempData对象的剖析

    另一篇文章,也对TempData 做了很详细的介绍,链接地址:https://www.jianshu.com/p/eb7a301bc536   . MVC中的 TempData 可以在Controll ...

  10. 腾讯云游戏服务平台CMatrix品牌全新升级为GameMatrix

    近日,隶属腾讯互娱公共研发运营体系(下文称CROS)下的云游戏服务平台CMatrix宣布进行品牌升级,启用全新商标Tencent GameMatrix,将原先代表云服务的“C”替换成游戏的英文单词“G ...