bzoj 4300: 绝世好题 dp
4300: 绝世好题
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://www.lydsy.com/JudgeOnline/problem.php?id=4300
Description
⋅1. If you touch a buoy before your opponent, you will get one point. For example if your opponent touch the buoy #2 before you after start, he will score one point. So when you touch the buoy #2, you won't get any point. Meanwhile, you cannot touch buoy #3 or any other buoys before touching the buoy #2.
⋅2. Ignoring the buoys and relying on dogfighting to get point.
If you and your opponent meet in the same position, you can try to
fight with your opponent to score one point. For the proposal of game
balance, two players are not allowed to fight before buoy #2 is touched by anybody.
There are three types of players.
Speeder:
As a player specializing in high speed movement, he/she tries to avoid
dogfighting while attempting to gain points by touching buoys.
Fighter:
As a player specializing in dogfighting, he/she always tries to fight
with the opponent to score points. Since a fighter is slower than a
speeder, it's difficult for him/her to score points by touching buoys
when the opponent is a speeder.
All-Rounder: A balanced player between Fighter and Speeder.
There will be a training match between Asuka (All-Rounder) and Shion (Speeder).
Since the match is only a training match, the rules are simplified: the game will end after the buoy #1 is touched by anybody. Shion is a speed lover, and his strategy is very simple: touch buoy #2,#3,#4,#1 along the shortest path.
Asuka is good at dogfighting, so she will always score one point by dogfighting with Shion, and the opponent will be stunned for T seconds after dogfighting.
Since Asuka is slower than Shion, she decides to fight with Shion for
only one time during the match. It is also assumed that if Asuka and
Shion touch the buoy in the same time, the point will be given to Asuka
and Asuka could also fight with Shion at the buoy. We assume that in
such scenario, the dogfighting must happen after the buoy is touched by
Asuka or Shion.
The speed of Asuka is V1 m/s. The speed of Shion is V2 m/s. Is there any possibility for Asuka to win the match (to have higher score)?
Input
Output
Sample Input
3
1 2 3
Sample Output
2
HINT
题意
题解:
直接dp就好了,dp[i]表示第i位为1的时候,最长多长
代码
#include<iostream>
#include<stdio.h>
using namespace std; int dp[];
int main()
{
int n;scanf("%d",&n);
for(int i=;i<n;i++)
{
int x;scanf("%d",&x);
int tmp = ;
for(int j=;j<=;j++)
if(x&(<<j))
tmp=max(dp[j]+,tmp);
for(int j=;j<=;j++)
if(x&(<<j))
dp[j]=max(dp[j],tmp);
}
int ans = ;
for(int i=;i<=;i++)
ans = max(ans,dp[i]);
printf("%d\n",ans);
}
bzoj 4300: 绝世好题 dp的更多相关文章
- bzoj 4300 绝世好题——DP
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4300 考虑 dp[ i ] 能从哪些 j 转移过来,就是那些 a[ j ] & a[ ...
- HYSBZ(BZOJ) 4300 绝世好题(位运算,递推)
HYSBZ(BZOJ) 4300 绝世好题(位运算,递推) Description 给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi&bi-1!=0(2<=i<= ...
- BZOJ 4300: 绝世好题 动态规划
4300: 绝世好题 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4300 Description 给定一个长度为n的数列ai,求ai的 ...
- 【递推】BZOJ 4300:绝世好题
4300: 绝世好题 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 564 Solved: 289[Submit][Status][Discuss] ...
- bzoj 4300: 绝世好题
4300: 绝世好题 Time Limit: 1 Sec Memory Limit: 128 MB Description 给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi& ...
- bzoj 4300: 绝世好题【dp】
设f[i][j]表示数列到i为止最后一项第j位为1的最大子序列长度,每次从i-1中1<<j&a[i]!=0的位+1转移来 然后i维是不需要的,答案直接在dp过程中去max即可 #i ...
- BZOJ 4300 绝世好题(位运算)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=4300 [题目大意] 给出一个序列a,求一个子序列b,使得&和不为0 [题解] ...
- bzoj 4300 绝世好题 —— 思路
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4300 记录一下 mx[j] 表示以第 j 位上是1的元素结尾的子序列长度最大值,转移即可. ...
- BZOJ 4300: 绝世好题 二进制
对于每一个数字拆位,然后维护一个大小为 30 左右的桶即可. code: #include <bits/stdc++.h> #define N 100006 #define setIO(s ...
随机推荐
- MBR与GRUB简介
在坛子里找到一篇关于grub和mbr工作原理的文章,以前一直都是一头雾水,今天转这文章学习下..哈.. 能正常工作的grub应该包 括一下文件:stage1.stage2.*stage1_5.menu ...
- Android 中屏幕点击事件的实现
在Android中如何用代码触发按钮点击事件?我想要触发代码执行按钮点击.实现对于单击按钮事件的模拟,触发单击按钮进入另一个界面. 就是声明一下什么moonlightcheese被声明了:在andro ...
- Matlab编程实例(3) 函数向左或向右平移N点 左移右移
%函数移动 close all; clear all; dir=input('请输入平移方向,“1”为向左,“2”为向右'); if dir~=1&&dir~=2;%输入控制 e ...
- 【LeetCode 221】Maximal Square
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and ret ...
- 【九度OJ】题目1078-二叉树遍历
题目 这道题和后面的两道题,题目1201和题目1009,主要内容是对递归的实现,在逻辑上,递归是容易理解的,这种实现方式和我们思考的方式是相吻合的.但是在转换为计算机语言时,要明确告知计算机应该从哪里 ...
- python os.walk()和os.path.walk()
一.os.walk() 函数声明:os.walk(top,topdown=True,onerror=None) (1)参数top表示需要遍历的顶级目录的路径. (2)参数topdown的默认值是“Tr ...
- Sqlserver作业-手把手带你体验
所谓Sql Server作业就是按照规定的时间执行指定的脚本,如果在SQL Server 里需要定时或者每隔一段时间执行某个存储过程或3200字符以内的SQL语句时,可以用管理-SQL Server代 ...
- 使用3D物体做GUI界面
通常来说,Unity自带的OnGUI不太好用,靠代码完成,在场景中无法直接编辑.所以,一般项目使用NGUI插件来做界面,但我这次要修改一个游戏,它没用NGUI,也没用OnGUI,而是使用类似NGUI的 ...
- Ineligible Devices 不被识别的设备
设备不可用,出现Ineligible Devices,如下图: 此错误因为 Xcode的Deployment Target 大于设备的,选择和设备一样活着低于设备的.如下图:
- 基于互联网的VOIP电话系统组建
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://wangchunhai.blog.51cto.com/225186/42379 ...