#286 (Div. 2) C. Mr. Kitayuta, the Treasure Hunter
2015-01-25 17:31
337 查看
#286 (Div. 2) C. Mr. Kitayuta, the Treasure Hunter
转载:http://blog.csdn.net/stl112514/article/details/42876613
题意:0~30000有30001个地方,每个地方有一个或多个金币,第一步走到了d,步长为d,以后走的步长可以是上次步长+1,-1或不变,走到某个地方可以收集那个地方的财富,现在问走出去(>30000)之前最多可以收集到多少财富。
转载:http://blog.csdn.net/stl112514/article/details/42876613
题意:0~30000有30001个地方,每个地方有一个或多个金币,第一步走到了d,步长为d,以后走的步长可以是上次步长+1,-1或不变,走到某个地方可以收集那个地方的财富,现在问走出去(>30000)之前最多可以收集到多少财富。
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int dp[30010][510],p[30010],goal,d; // v是现在的位置,l 为现在的步长; int dfs(int v,int l) { if(v>=goal) return p[v]; if(dp[v][l+250]!=-1) return dp[v][l+250]; int to=d+l+v,mx=0; if(to-1>v&&to-1<=30000) mx=max(mx,dfs(to-1,l-1)); if(to<=30000) mx=max(mx,dfs(to,l)); if(to+1<=30000) mx=max(mx,dfs(to+1,l+1)); dp[v][l+250]=p[v]+mx; return dp[v][l+250]; } int main() { int n; cin>>n>>d; while(n--) { int t; cin>>t; goal=max(t,goal); p[t]++; } memset(dp,-1,sizeof(dp)); cout<<dfs(d,0); }
相关文章推荐
- CF - 286 - div2 - C - Mr. Kitayuta, the Treasure Hunter (DP)
- Codeforces Round #286 (Div. 2) C题 Mr. Kitayuta, the Treasure Hunter (DFS+记忆化DP)
- Codeforces Round #286 (Div. 2) C. Mr. Kitayuta, the Treasure Hunter
- Codeforces Round #286 (Div. 2) C. Mr. Kitayuta, the Treasure Hunter dp
- Codeforces Round #286 (Div. 2)C. Mr. Kitayuta, the Treasure Hunter
- CodeForces 506 Div.1 A. Mr. Kitayuta, the Treasure Hunter
- Codeforces Round #286 Div.1 A Mr. Kitayuta, the Treasure Hunter --DP
- Codeforces Round #286 (Div. 2) C. Mr. Kitayuta, the Treasure Hunter——dp
- Codeforces Round #286 (Div. 2) C Mr. Kitayuta, the Treasure Hunter ( DP )
- Codeforces Round #286 (Div. 2) C. Mr. Kitayuta, the Treasure Hunter dp+范围压缩
- [Codeforces Round#286] A.Mr. Kitayuta, the Treasure Hunter 【Normal DP..】
- Mr. Kitayuta, the Treasure Hunter
- CF 505C(Mr. Kitayuta, the Treasure Hunter-Dp考虑可用范围)
- cf#186-C. Mr. Kitayuta, the Treasure Hunter-dp(预推断+offset)
- 【codeforces 505C】Mr.Kitayuta,the Treasure Hunter
- CF 286DIV2 C. Mr. Kitayuta, the Treasure Hunter(dp)
- Codeforces 505C Mr. Kitayuta, the Treasure Hunter DP+技巧优化
- 【CodeForces506A】【DP】【记忆化搜索】Mr. Kitayuta, the Treasure Hunter 题解
- CF505C——Mr. Kitayuta, the Treasure Hunter(DP)
- [Codeforces Round #286 DIV1A (CF506A)] Mr. Kitayuta, the Treasure Hunter