标签:using fir fine sizeof rop ace clu scan ldb
#include<bits/stdc++.h> using namespace std; //#include<ext/rope> //using namespace __gnu_cxx //#include<ext/pb_ds/priority_queue.hpp> //using namespace __gnu_pbds; #define lowbit(x) (x&-x) #define pb(x) push_back(x) #define all(x) (x).begin(),(x).end() #define clr(a,b) memset(a,b,sizeof(a)) #define caze(T) for(scanf("%d",&T);T;T--) #define inf (1<<30) #define Endl (‘\n‘) #define fi first #define se second #define db double #define ldb long double #define ll long long #define pll pair<ll,ll> #define pli pair<ll,int> #define pii pair<int,int> #define ull unsigned long long #define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) ll dp[300030][3]; //0:unuse,1:using,2:used ll a[300030]; int main() { int n; ll x; ll ans=0; cin>>n>>x; for(int i=1;i<=n;++i) cin>>a[i]; clr(dp[0],0); for(int i=1;i<=n;++i) { dp[i][0]=max(dp[i-1][0],0LL)+a[i]; dp[i][1]=max(0LL,max(dp[i-1][0],dp[i-1][1]))+a[i]*x; dp[i][2]=max(0LL,max(dp[i-1][1],dp[i-1][2]))+a[i]; for(int j=0;j<3;++j) ans=max(ans,dp[i][j]); } cout<<ans<<Endl; }
标签:using fir fine sizeof rop ace clu scan ldb
原文地址:https://www.cnblogs.com/violet-acmer/p/10755543.html