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) ...
随机推荐
- 浏览器输入URL后HTTP请求返回的完整过程
图:
- Java程序基本优化
1.尽量指定类的final修饰符,因为带有final修饰符的类是不可派生的. 2.尽量重用对象. 3.尽量使用局部变量. 4.不要重复初始化变量. 5.在Java+Oracle的应用系统开发中,Jav ...
- vue项目真机测试
1.在项目中重启命令行运行ipconfig(如果是ios系统运行ifconfig)获取到项目在本机运行的ip地址 2.在项目的package.json中修改允许访问ip地址(--host 0.0.0. ...
- LibreOJ #6001. 「网络流 24 题」太空飞行计划
\(\quad\) 与网络流有关的最值有三个:最大流,最小费用,最小割.这道题是最小割.想了好久,终于想明白最小割应该怎么用. \(\quad\) 先找出矛盾的事物.在这道题中,两件事是矛盾的:做实验 ...
- 解决国内GitHub加载慢的问题
一.有条件的可以翻墙. 二.在C:\Windows\System32\drivers\etc修改host文件 如果没有权限,那么复制到桌面,添加以下内容再粘贴回去: # GitHub Start 19 ...
- 一个Win32程序的进化------转载
一个Win32程序的进化 转载 weixin_34273046 发布于2017-11-15 10:53:00 阅读数 10 收藏 展开 一.为什么要学Win32 要回答这个问题,我们就要先搞清 ...
- SqlParameter 类
SqlParameter 类 表示 SqlCommand 的参数,也可以是它到 DataSet 列的映射.无法继承此类. 命名空间: System.Data.SqlClient 程序集: System ...
- 一、什么是Velocity及简单示例
1.velocity简介: velocity是一个java模板引擎技术,任何人可以使用这种简单而又强有力的模板语言去获取java对象. 在使用Velocity进行web开发时,web开发人员和j ...
- tensorflow之逻辑回归模型实现
前面一篇介绍了用tensorflow实现线性回归模型预测sklearn内置的波士顿房价,现在这一篇就记一下用逻辑回归分类sklearn提供的乳腺癌数据集,该数据集有569个样本,每个样本有30维,为二 ...
- 实时监听input输入的变化(兼容主流浏览器)
遇到如此需求,首先想到的是change事件,但用过change的都知道只有在input失去焦点时才会触发,并不能满足实时监测的需求,比如监测用户输入字符数. 在经过查阅一番资料后,欣慰的发现firef ...