cf 506 A. Mr. Kitayuta, the Treasure Hunter
不知道这个sb题怎么做错了。。
/*#include <bits/stdc++.h>
#define LL long long
using namespace std;
inline int ra()
{
int x=0,f=1; char ch=getchar();
while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
return x*f;
}
int n,s,tot[30005],f[30005],ans;
bool can[30005][605];
const int T=300;
int main()
{
n=ra(); s=ra(); can[0][T]=1;
for (int i=1; i<=n; i++) tot[ra()]++;
f[0]=tot[0];
for (int i=0; i<=30000; i++)
{
for (int j=-300; j<=300; j++)
{
if (s+j<=0) continue;
if (can[i][j+T] && s+i+j<=30000)
{
f[s+i+j]=max(f[i+j+s],f[i]+tot[s+i+j]);
can[i+j+s][j+T]=1;
can[i+j+s][j+1+T]=1;
can[i+j+s][j-1+T]=1;
}
}
ans=max(ans,f[i]);
}
cout<<ans;
return 0;
}*/
#include <bits/stdc++.h>
#define LL long long
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>'') {if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<='') {x=x*+ch-''; ch=getchar();}
return x*f;
}
const int T=;
int n,s,ans;
int tot[],f[][];
int main()
{
memset(f,-,sizeof(f));
n=ra(); s=ra();
for (int i=; i<=n; i++) tot[ra()]++;
f[s][T/]=;
for (int i=s; i<=; i++)
for (int j=; j<=T; j++)
{
int t=j-T/+s;
if (i-t>= && t>)
{
if (f[i-t][j-]!=-) f[i][j]=max(f[i][j],f[i-t][j-]);
if (f[i-t][j]!=-) f[i][j]=max(f[i][j],f[i-t][j]);
if (f[i-t][j+]!=-) f[i][j]=max(f[i][j],f[i-t][j+]);
if (f[i][j]!=-) f[i][j]+=tot[i];
ans=max(f[i][j],ans);
}
}
cout<<ans;
return ;
}
cf 506 A. Mr. Kitayuta, the Treasure Hunter的更多相关文章
- codeforces 505C C. Mr. Kitayuta, the Treasure Hunter(dp)
题目链接: C. Mr. Kitayuta, the Treasure Hunter time limit per test 1 second memory limit per test 256 me ...
- Codefores 506A Mr. Kitayuta, the Treasure Hunter( DP && dfs )
A. Mr. Kitayuta, the Treasure Hunter time limit per test 1 second memory limit per test 256 megabyte ...
- [Codeforces 505C]Mr. Kitayuta, the Treasure Hunter
Description The Shuseki Islands are an archipelago of 30001 small islands in the Yutampo Sea. The is ...
- [Codeforces Round#286] A.Mr. Kitayuta, the Treasure Hunter 【Normal DP..】
题目链接:CF#286 - A 这场CF就这样爆零了...我真是太蒟蒻了... 题目分析 比赛的时候看到A题就发现不会,之后一直也没想出来,于是就弃了,还好不提交也不掉Rating... 比赛后看评论 ...
- 【codeforces 505C】Mr.Kitayuta,the Treasure Hunter
[题目链接]:http://codeforces.com/problemset/problem/505/C [题意] 一开始你跳一步长度为d; 之后你每步能跳d-1,d,d+1这3种步数; 然后在路上 ...
- Codeforces Round #286 Div.1 A Mr. Kitayuta, the Treasure Hunter --DP
题意:0~30000有30001个地方,每个地方有一个或多个金币,第一步走到了d,步长为d,以后走的步长可以是上次步长+1,-1或不变,走到某个地方可以收集那个地方的财富,现在问走出去(>300 ...
- codeforces 505C Mr. Kitayuta, the Treasure Hunter(dp)
题意:有30001个岛,在一条线上,从左到右编号一次为0到30000.某些岛屿上有些宝石.初始的时候有个人在岛屿0,他将跳到岛屿d,他跳跃的距离为d.如果当前他跳跃的距离为L,他下一次跳跃的距离只能为 ...
- 505C Mr. Kitayuta, the Treasure Hunter
传送门 题目大意 一共有30000个位置,从第0个位置开始走,第一次走k步,对于每一次走步,可以走上一次的ki+1 ,ki ,ki-1步数(必须大于等于1),每个岛上有value,求最大能得到的val ...
- Codeforces 505C Mr. Kitayuta, the Treasure Hunter:dp【考虑可用范围】
题目链接:http://codeforces.com/problemset/problem/505/C 题意: 有n个宝石,分别在位置p[i].(1 <= n,p[i] <= 30000) ...
随机推荐
- MySQL 之存储引擎与数据类型与数据约束
一.存储引擎场景 1.InnoDB 用于事务处理应用程序,支持外键和行级锁.如果应用对事物的完整性有比较高的要求,在并发条件下要求数据的一致性,数据操作除了插入和查询之外,还包括很多更新和删除操作,那 ...
- vue项目真机测试
1.在项目中重启命令行运行ipconfig(如果是ios系统运行ifconfig)获取到项目在本机运行的ip地址 2.在项目的package.json中修改允许访问ip地址(--host 0.0.0. ...
- 小程序PromiseAll定义
var promiseAll = (funcs, callback) =>{ var promises = [] for(var i=0; i<funcs.length; i++){ pr ...
- Duilib自定义控件
新版博客已经搭建好了,有问题请访问 htt://www.crazydebug.com 在公司二期项目中为了将谷歌内核嵌入到duilib中,采用了自定义duilib控件的方法,由于也是第一次用duili ...
- Android数据库高手秘籍(二):创建表和LitePal的基本用法
原文:http://blog.jobbole.com/77157/ 上一篇文章中我们学习了一些Android数据库相关的基础知识,和几个颇为有用的SQLite命令,都是直接在命令行操作的.但是我们都知 ...
- CH8 课后习题
8.1和8.2 #include <iostream> using namespace std; istream& f(istream& in) { int v; in & ...
- django 自定义模版过滤器
自定义的模版过滤器必须要放在app中,并且该app必须在INSTALLED_APPS中进行安装.然后再在这个app下面创建一个python包叫做templatetags(这个名字是固定的,不能随意更改 ...
- myeclipse中svn图标状态不显示问题的解决办法
myeclipse中svn图标状态不显示问题的解决办法 博客分类: svn SVNMyeclipse工作WindowsC myeclipse中使用 svn 插件,原本正常,未作任何更改,突然有一天, ...
- windowsService 程序
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- Day12:看节目对于高考的想法
今天看了一个科教频道的说高考的节目~ 老师问孩子的为什么要高考~ 学生说:为了以后不用辛苦,不用像爸妈一样再大冬天奔波,不辜负爸妈的期望~ 学习!高考!科举制度害了多少读书人?! 现在的高考跟科举有区 ...