题目大意:现在有一个数列,还有一个数字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. numpy中多维数组的绝对索引

    这涉及到吧多维数组映射为一维数组. 对于3维数组,有公式: def MAP(x,y,z): return y_s * z_s * x + z_s * y + z 此公式可以推广到N维 测试代码:(两个 ...

  2. CF1248E Queue in the Train

    题目链接 problem 火车上的一列人要去排队接水.每个人都会在某个特定的时刻口渴.口渴之后他要去排队接水,如果他前面的座位有人已经在排队或者正在接水,那么他就不会去排队.否则他就会去排队.每个人接 ...

  3. AFO!

    \(update:2019-12-13\) 成绩已经出了,我的OI生涯也算是正式结束了.虽然成绩并不满意,但好在也是收获了一个省一(虽然我不一定用).总的来说,作为正式选手不到两年半的OI之路走得并不 ...

  4. 《最优化导论第4版》高清中文版PDF+高清英文版PDF+习题题解

    <最优化导论第4版>高清中文版PDF+高清英文版PDF+习题题解 存放在语雀 凸优化 · 语雀

  5. Linux 学习记录一(安装、基本文件操作).

    Linux 名字的由来,是当时作者将初版的 Linux 发布在网上,供别人下载完善,而那个核心文件夹就叫 Linux,就这么叫着了.而为什么 Linux 的吉祥物是一只企鹅呢?是因为当时大家要发行稳定 ...

  6. 用keras构建自己的网络层 TensorFlow2.0教程

    1.构建一个简单的网络层 from __future__ import absolute_import, division, print_function import tensorflow as t ...

  7. 1+X证书web前端开发中级对应课程分析

    官方QQ群 1+x 证书 Web 前端开发 JavaScript 专项练习 http://blog.zh66.club/index.php/archives/198/ 1+x 证书 Web 前端开发初 ...

  8. IT兄弟连 Java语法教程 流程控制语句 循环结构语句2

    双重for循环 如果把一个循环放在另一个循环体中,那么就可以形成嵌套循环,也就是双重for循环,当然嵌套循环也可以是for循环嵌套while循环,也可以是while循环嵌套while循环……,即各种类 ...

  9. 使用suds模块进行封装,处理webservice类型的接口

    import json from suds.client import Client class HandleWebservice: ''' 定义一个webservice类型的接口处理类 ''' de ...

  10. Http Header的Transfer-Encoding

    Transfer-Encoding,是一个 HTTP 头部字段,字面意思是「传输编码」.实际上,HTTP 协议中还有另外一个头部与编码有关:Content-Encoding(内容编码).Content ...