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) ...
随机推荐
- 在Centos 7.7下用minikube部署单节点kubernetes.
centos8 下用yum安装docker-ce会报错,说明docker-ce对centos8支持还不太好.所以在centos7.7下安装 先更新一下系统 yum update 安装 yum工具, ...
- C#Winfrom实现Skyline画直线功能
C#Winfrom实现Skyline画直线功能 前言: 这里记录了我在学习Skyline二次开发中所遇到的问题,适合刚接触Skyline二次开发的同学查看使用,从逻辑到代码逐一详解,但是还是重在理解, ...
- 你需要知道的 JavaScript 类(class)的这些知识
作者: Dmitri Pavlutin译者:前端小智来源:dmitripavlutin 点赞再看,养成习惯 本文 GitHub https://github.com/qq44924588... 上已经 ...
- winform跳转到bs
private void button7_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("http ...
- mac允许安装任何来源的软件
如果在“系统偏好设置”--“安全性与隐私”--“通用”版面没有像下面的选项.那么请打开终端,使用命令行操作,之后重新进刚刚的设置界面,会出现“任何来源”的选项. 命令行:(请复制使用) sudo sp ...
- js面试代码中的“坑”
1.typeof 对类型的判断 (function() { return typeof arguments; } )(); 答案:"Object" 解释:arguments是一个伪 ...
- linux 查看Apache Tomcat日志访问IP前10
访问日志名:localhost_access_log.2019-01-29.txt 日志格式示例 /Nov/::: +] /Nov/::: +] /Nov/::: +] /Nov/::: +] /No ...
- Mybatis入门(五)属性名和字段名不一致解决
在学Mybatis的时候都需要创建一个实体类,但创建实体类的变量必须和数据库的一样,这章就来解决这个有趣的问题 目录: 问题是这样: 输出的结果是: password为空,这就很难受: 解决方法: 第 ...
- Day9 - K - Yue Fei's Battle HDU - 5136
Yue Fei is one of the most famous military general in Chinese history.He led Southern Song army in t ...
- java 之word转html
jar包 链接: https://pan.baidu.com/s/13o2CZTwM-Igx6wcoyEu_ug 密码: n95q package com.bistu.service; import ...