注意转移方程 分1.凭空买 2.不买不卖 3.在原来基础上买 4.在原来基础上卖 四种情况 head=1,tail=0;再判断一下head<=tail也可以 #include<bits/stdc++.h> using namespace std; ; int n,m,w,ans; int ap[N],bp[N],as[N],bs[N]; int f[N][N]; ],head=,tail=; int main() { scanf("%d%d%d",&n,&am…
Cut the Sequence Time Limit: 2000MS Memory Limit: 131072K Total Submissions: 8764 Accepted: 2576 Description Given an integer sequence { an } of length N, you are to cut the sequence into several parts every one of which is a consecutive subseque…
传送门 就是个单调队列+DP嘛. ——代码 #include <cstdio> ; , t = , ans = ~( << ); int q[MAXN], a[MAXN], f[MAXN]; inline int min(int x, int y) { return x < y ? x : y; } int main() { int i; scanf("%d %d", &n, &m); ; i <= n; i++) scanf(&qu…