POJ 1976 A Mini Locomotive】的更多相关文章

题意:给出一列火车,可以由三个火车头拉,每个火车头最多拉m节车厢(这m节车厢需要保持连续),再给出n节车厢,每节车厢的人数,问最多能够载多少人到终点. 可以转化为三个长度相等的区间去覆盖n个数,使得这些数的和最大. 用dp[i][j]表示前i个数用j个区间覆盖所得到的最大值,状态转移则为覆盖第i个数,或者不覆盖第i个数. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm…
$dp$. 要求选择$3$个区间,使得区间和最大.$dp[i][j]$表示前$i$个数中选择了$j$段获得的最大收益. #include <cstdio> #include <cmath> #include <set> #include <cstring> #include <algorithm> using namespace std; int T,n,k; ][]; ]; int main() { scanf("%d",&…
A Mini Locomotive Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 2485   Accepted: 1388 Description A train has a locomotive that pulls the train with its many passenger coaches. If the locomotive breaks down, there is no way to pull the…
题目链接: https://vjudge.net/problem/POJ-1976 题目描述: A train has a locomotive that pulls the train with its many passenger coaches. If the locomotive breaks down, there is no way to pull the train. Therefore, the office of railroads decided to distribute…
题目http://poj.org/problem?id=1976 分析:给n个数,求连续3段和的最大值. 这个题目的思考方式很像背包问题. dp[i][j]表示前i个数字,放在j段的最大值. 如果选了第i个数,则有 dp[i-1][j]  如果不选第i个数,由于题目是要连续的, 则有dp[i-m][j-1]+sum[i]-sum[i-m] ,这里i-m是要保证连续. dp[i][j]=max{ dp[i-1][j] ,dp[i-m][j-1]+sum[i]-sum[i-m]  } #includ…
 /*  题意:选出3个连续的 数的个数  为K的区间,使他们的和最大 分析: dp[j][i]=max(dp[j-k][i-1]+value[j],dp[j-1][i]);   dp[j][i]:从j个数种选出i个连续区间  数值的最大和 value[j]:第j个区间内的数的和 和背包有点像,但要活用   */   #include <cstdio> #include <cstring> #include <iostream> using namespace std;…
  A OpenJ_Bailian 1088 滑雪     B OpenJ_Bailian 1579 Function Run Fun     C HDU 1078 FatMouse and Cheese     D POJ 3280 Cheapest Palindrome     E OpenJ_Bailian 1976 A Mini Locomotive     F OpenJ_Bailian 2111 Millenium Leapcow     G OpenJ_Bailian 1141 B…
首先我是按这篇文章来确定题目的. poj3624 Charm Bracelet 模板题 没有要求填满,所以初始化为0就行 #include<cstdio> #include<algorithm> #include<cmath> #include<iostream> #include<cstring> using namespace std; ]; ]; int n,m; +]; int main() { // freopen("inpu…
poj3624 Charm Bracelet 模板题 没有要求填满,所以初始化为0就行 #include<cstdio> #include<iostream> using namespace std; #define N 15010 int n,m,v[N],c[N],f[N]; int main(){ scanf("%d%d",&n,&m); ;i<=n;i++) scanf("%d%d",&v[i],&…
A train has a locomotive that pulls the train with its many passenger coaches. If the locomotive breaks down, there is no way to pull the train. Therefore, the office of railroads decided to distribute three mini locomotives to each station. A mini l…