HDU6024:Building Shops(简单DP)】的更多相关文章

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…
Building Shops                                                             Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)                                                                                          …
传送门 题意 在一条直线上有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…
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…
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 33384    Accepted Submission(s): 15093 Problem Description Nowadays, a kind of chess game called “Super Jumping!…
题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. 简单dp,dp[i]表示取i时zui最大和为多少,方程为dp[i] = max(dp[i - 1] , dp[i - 2] + cont[i]*i). #include <bits/stdc++.h> using namespace std; typedef __int64 LL; ; LL a…
Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/attachments Description Noura Boubou is a Syrian volunteer at ACM ACPC (Arab Collegiate Programming Contest) since 2011. She graduated from Tishreen Un…
题目链接 这道题也是简单dp里面的一种经典类型,递推式就是dp[i] = min(dp[i-150], dp[i-200], dp[i-350]) 代码如下: #include<iostream> #include <stdio.h> using namespace std; ]; int main() { ; i < ; i++) dp[i] = i; ; i < ; i++) { int minn; ) dp[i] = dp[i - ]; ) dp[i] = min…
J - 简单dp Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description It is a little known fact that cows love apples. Farmer John has two apple trees (which are conveni…
I - 简单dp 例题扩展 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HD…