hdu 4563
hdu 4563
- 把每个命令走的距离抽象成完全背包
- 枚举最后一个不是整点走完的命令
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
const double N = -1e9;
double DP[105];
int xx[105],yy[105];
double cal(double t,int v)
{
return -9.8*t*t/2.0+v*t;
}
double check(int x,int n,int L)
{
for(int i = 0; i <= 100; i++)
DP[i] = N;
DP[0] = 0;
for(int i = 0; i < n; i++) //选第几个命令
{
if(i == x) continue;
for(int j = L; j >= 0; j--) //到距离j
{
for(int k = 0; k <= L/xx[i]; k++) //命令i走k秒
{
if(j >= k*xx[i])
{
DP[j] = max(DP[j],DP[j-k*xx[i]]+cal(k,yy[i]));
}
}
}
}
double ans = N;
for(int i = 0; i <= L; i++)
{
ans = max(ans,DP[i]+cal(1.0*(L-i)/xx[x],yy[x])); //枚举最后一个命令是从哪个
}
return ans;
}
void solve(int cnt)
{
int nn,L;
scanf("%d %d",&nn,&L);
for(int i = 0; i < nn; i++)
{
scanf("%d %d",&xx[i],&yy[i]);
}
double ans = N;
for(int i = 0; i < nn; i++)
{
ans = max(ans,check(i,nn,L)); //枚举最后一个命令是哪个,因为只有最后一个命令不是整点到达
}
printf("Case %d: %.3f\n",cnt,ans);
}
int main(void)
{
int t,cnt = 1;
scanf("%d",&t);
while(t--)
solve(cnt++);
return 0;
}
hdu 4563的更多相关文章
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
- HDU 3791二叉搜索树解题(解题报告)
1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...
- hdu 4329
problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟 a. p(r)= R'/i rel(r)=(1||0) R ...
随机推荐
- Redhat 7.0 安装桌面环境
1.安装桌面环境组件 #yum groupinstall "Server with GUI" 2.切换到图形界面 #startx 3.设置启动模式为图形界面 #rm /etc/sy ...
- tarjan模板 强联通分量+割点+割边
// https://www.cnblogs.com/stxy-ferryman/p/7779347.html ; struct EDGE { int to, nt; }e[N*N]; int hea ...
- 注解到处excel
package com.cxy.domain.poi; import java.lang.annotation.ElementType; import java.lang.annotation.Ret ...
- boost 条件变量
// boost 条件变量 // 做个简单的笔记 #include <boost/thread/mutex.hpp> #include <boost/thread/condition ...
- buff/cache内存占用过多
通过free -m 查看到 buff/cache的值比较大,导致可使用的内存有120M左右了 通过下面的命令,清除缓存 echo 1 > /proc/sys/vm/drop_caches ech ...
- Python中虚拟环境venv的基本用法
环境windows 7 venv为python3中的默认库,无需安装. 创建新的venv方法, 在当前文件夹下执行cmd,输入如下代码 python -m venv bob bob为需要创建的文件夹名 ...
- Java 多线程 - Volatile关键字
作者: dreamcatcher-cx 出处: <http://www.cnblogs.com/chengxiao/> 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明 ...
- RocketMQ源码分析之从官方示例窥探:RocketMQ事务消息实现基本思想
摘要: RocketMQ源码分析之从官方示例窥探RocketMQ事务消息实现基本思想. 在阅读本文前,若您对RocketMQ技术感兴趣,请加入RocketMQ技术交流群 RocketMQ4.3.0版本 ...
- Docker系列(七):Docker图形化管理和监控
Docker管理工具之官方三剑客 Docker Machine是什么鬼 从前 现在 你需要登录主机,按照主机及操作系统特有的安装以及配置步骤安装Docker,使其 能运行Docker容器. Docke ...
- Python 实现0-1背包
代码: import numpy as np c=10 #背包容量 w=[2,2,6,5,4] #物品重量 v=[5,3,5,4,6] #物品价值 flag =[0,0,0,0,0] m=np.zer ...