Building Shops】的更多相关文章

Building Shops                                                             Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)                                                                                          …
Building Shops Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 4446    Accepted Submission(s): 1551 Problem Description HDU’s n classrooms are on a line ,which can be considered as a number li…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6024 Problem Description HDU’s n classrooms are on a line ,which can be considered as a number line. Each classroom has a coordinate. Now Little Q wants to build several candy shops in these n classrooms…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 379    Accepted Submission(s): 144 Problem Description HDU’s n classrooms are on a line ,which can be considered as a number line. Each classro…
https://cn.vjudge.net/problem/HDU-6024 分开考虑某一点种与不种,最后取二者的最小值. dp[i][1] = min(dp[i-1][0], dp[i-1][1])+c[i]; dp[i][0]则是j从i-1~1递减,判断当j种是,i的最小值,然后取总的最小. 注意dp初始化为INF,以及要开long long #include<iostream> #include<cstdio> #include<cstring> #include…
$dp$. $dp[i]$表示到$i$位置,且$i$位置建立了的最小花费,那么$dp[i] = min(dp[k]+cost[i+1][k-1])$,$k$是上一个建的位置.最后枚举$dp[i]$,加上最后一段的花费,取个最小值即可. #include <bits/stdc++.h> using namespace std; ; const long long inf=1e18; int n; struct X { long long pos; long long cost; }s[]; bo…
题意 有n个教室排成一排,每个教室都有一个坐标,现在,小Q想建一些糖果商店,在这n个教室里面.总的花费有两部分,在教室i建一个糖果屋需要花费ci,对于没有任何糖果屋的P,需要的花费为这个教室到它左边有糖果商店的距离.怎么建糖果商店才能使花费最少?n<=3000. 分析 比较显然的dp,每个教室有两种选择,建糖果教室或者 不建糖果教室.f[i][0]第i个教室不建糖果商店时的最少花费.f[i][1]第i个教室建糖果商店时的最少花费.直接转移的话复杂度时O(N^3)的.我们可以预处理出所有i,j直接…
传送门 题意 在一条直线上有n个教室,现在要设置糖果店,使得最后成本最小,满足以下两个条件: 1.若该点为糖果店,费用为cost[i]; 2.若不是,则为loc[i]-最近的糖果店的loc 分析 dp方程不好想,我们观察一下,如果在第i个点设置最后一个糖果店,那么它将影响到它之前的糖果店,那么第i个点的费用必然由前i-1个的位置上费用最小的糖果店转移过来,这里糖果店费用计算为\(cost[i]+\sum_{j=i+1}^n(dis[j]-dis[i])\),那么转移方程为\[dp[i]=dp[j…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6024 题意:有n个room在一条直线上,需要这这些room里面建造商店,如果第i个room建造,则要总花费加上Ci , 不建造的话, 总花费就要加上去左边的第一间商店的距离.求总的最小花费. 题解:dp1[i] 为第i个建造的最小花费, dp2[i] 为第i个不建造的最小花费. dp1[i] = min(dp1[i-1], dp2[i-1]) + Ci dp2[i] = min(dp2[i], dp…
Building Shops Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description HDU’s n classrooms are on a line ,which can be considered as a number line. Ea…