cf286C Mr. Kitayuta, the Treasure Hunter dp
来源:互联网 发布:用java开发的大型游戏 编辑:程序博客网 时间:2024/04/29 19:24
很容易想到用dp[i][len]表示在i位置,跳跃len长度的最大值,但i和len都<=30000,太大。其实len的值在[d-250,d+250]之间,可能为负,+base,len-d+base在[0,500],于是dp[i][j]表示在位置i,跳跃j+d-base。
#include<iostream>#include<string>#include<cstring>#include<cstdio>#include<cmath>#include<iomanip>#include<map>#include<algorithm>#include<queue>#include<set>#define inf 10000000#define pi acos(-1.0)#define eps 1e-8#define seed 131using namespace std;typedef pair<int,int> pii;typedef unsigned long long ULL;typedef long long LL;const int maxn=100005;int dp[30005][605];int n,d;int num[30005];int base=250;int main(){ int a; memset(num,0,sizeof(num)); scanf("%d%d",&n,&d); for(int i=0;i<n;i++) { scanf("%d",&a); num[a]++; } memset(dp,0,sizeof(dp)); num[d]++; dp[d][base]=num[d]; int mx=num[d]; for(int i=d+1;i<=30000;i++) { for(int j=0;j<600;j++) { int len=j+d-base; if(len<=0) continue; if(i-len>0&&dp[i-len][j-1]!=0) dp[i][j]=max(dp[i][j],dp[i-len][j-1]+num[i]); if(i-len>0&&dp[i-len][j]!=0) dp[i][j]=max(dp[i][j],dp[i-len][j]+num[i]); if(i-len>0&&dp[i-len][j+1]!=0) dp[i][j]=max(dp[i][j],dp[i-len][j+1]+num[i]); mx=max(mx,dp[i][j]); } } cout<<mx-1<<endl; return 0;}
0 0
- cf286C Mr. Kitayuta, the Treasure Hunter dp
- dp Codeforces505C Mr. Kitayuta, the Treasure Hunter
- Mr. Kitayuta, the Treasure Hunter
- 【DP】 Codeforces Round #286 A - Mr. Kitayuta, the Treasure Hunter
- Codeforces Round #286 C. Mr. Kitayuta, the Treasure Hunter dp
- CF505C——Mr. Kitayuta, the Treasure Hunter(DP)
- codeforces 505C Mr. Kitayuta, the Treasure Hunter(dp)
- codeforces 505C Mr. Kitayuta, the Treasure Hunter(DP)
- dp cf C. Mr. Kitayuta, the Treasure Hunter
- codeforces 505C C. Mr. Kitayuta, the Treasure Hunter (dp)
- codeforces 505C Mr. Kitayuta, the Treasure Hunter(DP)
- CF_505C 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+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)
- CF 286DIV2 C. Mr. Kitayuta, the Treasure Hunter(dp)
- CF 505C(Mr. Kitayuta, the Treasure Hunter-Dp考虑可用范围)
- 2015 年 JXNU_ACS 算法组寒假第一次周赛 1002 稳定的排序
- HDU 1255 覆盖的面积(线段树扫描线)
- eclipse 操作基础
- 2015 年 JXNU_ACS 算法组寒假第一次周赛 1003 第K小的数
- GUI菜单——菜单条、菜单、子条目之间关系
- cf286C Mr. Kitayuta, the Treasure Hunter dp
- PHP运行模式
- 域控渗透技巧
- 在阿里云的CentOS上安装docker
- 2015 年 JXNU_ACS 算法组寒假第一次周赛 1004 盘古开天辟地
- Minion security project and 分布式nmap
- Java虚拟机参数及JVM监控工具
- auc指标含义的理解
- 详细解说STL hash_map系列