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) ...
随机推荐
- 郁闷的 IE6/7/8 所遇兼容问题
IE6,7只支持inline元素设置为inline-block,但不支持block元素转换成inline-block,所以非inline元素在IE6,7下要转换成inline-block,需先转换成i ...
- 124、Java面向对象之引用传递实例二,String类型按值传递
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...
- VMware安装CentOS操作系统详细步骤
目录 创建虚拟机(买电脑) 1. 创建新虚拟机 2. 自定义配置虚拟机 3. 选择虚拟机硬件兼容性 4. 安装虚拟机创建系统 5. 选择虚拟机操作系统 6. 设置虚拟机名字和存放位置 7. 设置虚拟机 ...
- 一个Java的小问题
老师今天在讨论群里抛出了一个问题,让大家尝试思考一下他所给的一段代码输出是什么. 其代码如下: class T { void foo() { this.bar(); } void bar() { Sy ...
- (编辑状态下)Reset及OnValidate使用
using UnityEngine; using System.Collections; public class Demo : MonoBehaviour { #if UNITY_EDITOR vo ...
- CSS-font
font:[ [ <' font-style '> || <' font-variant '> || <' font-weight '> ]? <' font ...
- Echarts 折线图y轴标签值过长 显示
参考: https://blog.csdn.net/dandelion_drq/article/details/79270597 改变Y轴单位:https://www.cnblogs.com/cons ...
- STM32学习笔记:IIC通信协议详解(附带软件模拟源码)
什么是IIC(I2C)? IIC 即Inter-Integrated Circuit(集成电路总线),这种总线类型是由飞利浦半导体公司设计出来的一种简单.双向.二线制.同步串行总线.它是一种多向控制总 ...
- PAT (Advanced Level) 1140~1143:1140模拟 1141模拟 1142暴力 1143 BST+LCA
1140 Look-and-say Sequence(20 分) 题意:观察序列D, D1, D111, D113, D11231, D112213111, ...,显然后一个串是对前一个串每一小段连 ...
- HiBench成长笔记——(2) CentOS部署安装HiBench
安装Scala 使用spark-shell命令进入shell模式,查看spark版本和Scala版本: 下载Scala2.10.5 wget https://downloads.lightbend.c ...