题意:

有n个宽度为w的门,给出门的左端点的水平位置x和高度y,和恒定的垂直速度,现有s个速度,求能通过这n个门的最大速度。

分析:

二分速度判断

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <complex>
#include <cassert>
#include <utility>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
#define lson l,m,rt<<1
#define pi acos(-1.0)
#define rson m+1,r,rt<<11
#define All 1,N,1
#define N 1000010
#define read freopen("in.txt", "r", stdin)
const ll INFll = 0x3f3f3f3f3f3f3f3fLL;
const int INF= 0x7ffffff;
const int mod = ;
int w,n,vh;
int x[N],y[N],s[N];
int solve(int v){
double ll=x[],rr=x[]+w;
for(int i=;i<n;++i){
double t=1.0*(y[i]-y[i-])/v;
ll-=t*vh;
rr+=t*vh;
if(ll>1.0*(x[i]+w)||rr<1.0*x[i])return ;
ll=max(ll,1.0*x[i]);
rr=min(rr,1.0*x[i]+w);
}
return ;
}
int main()
{
int c,len;
scanf("%d",&c);
while(c--){
scanf("%d%d%d",&w,&vh,&n);
for(int i=;i<n;++i)
scanf("%d%d",&x[i],&y[i]);
scanf("%d",&len);
for(int i=;i<=len;++i)
scanf("%d",&s[i]);
sort(s+,s+len+);
int l=,r=len,f=,tmp;
while(l<=r){
int mid=(l+r)>>;
if(solve(s[mid])){
tmp=mid;
l=mid+;
f=;
}
else r=mid-;
}
if(f)
printf("%d\n",s[tmp]);
else printf("IMPOSSIBLE\n");
}
return ;
}

Slalom的更多相关文章

  1. 【Codeforces720D】Slalom 线段树 + 扫描线 (优化DP)

    D. Slalom time limit per test:2 seconds memory limit per test:256 megabytes input:standard input out ...

  2. 【CF720D】Slalom 扫描线+线段树

    [CF720D]Slalom 题意:一个n*m的网格,其中有k个矩形障碍,保证这些障碍不重叠.问你从(1,1)走到(n,m),每步只能往右或往上走,不经过任何障碍的方案数.两种方案被视为不同,当且仅当 ...

  3. 论文笔记[Slalom: Fast, Verifiable and Private Execution of Neural Networks in Trusted Hardware]

    作者:Florian Tramèr, Dan Boneh [Standford University] [ICLR 2019] Abstract 为保护机器学习中隐私性和数据完整性,通常可以利用可信 ...

  4. UVa (二分) 11627 Slalom

    题意: 有宽度相同的水平的n个旗门,水平(纵坐标严格递增)滑行的最大速度为Vh(水平速度可以任意调节).然后还有S双滑雪板,每双滑雪板的垂直速度一定. 然后求能通过的滑板鞋的最大速度. 分析: 显然, ...

  5. UVa 11627 - Slalom 二分. oj错误题目 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  6. UVA 11627 Slalom(二分)

    二分,判断的时候,一个点一个点的考虑肯定是不行啦,考虑的单位是一个区间, 每次左端点尽量向左边移动,右端点尽量向右,得到下次可以达到的范围,检查一下和下一个区间有没有交集. #include<b ...

  7. [cf720D]Slalom

    对于每一行,这些障碍将其划分为若干段,记第$i$行($y=i$时)从左到右第$j$段为$[l_{i,j},r_{i,j}]$ 显然一条路径恰好经过每一行中的一段,且两种方案不同当且仅当其中经过的一段不 ...

  8. 【转】最短路&差分约束题集

    转自:http://blog.csdn.net/shahdza/article/details/7779273 最短路 [HDU] 1548 A strange lift基础最短路(或bfs)★254 ...

  9. ACM计算几何题目推荐

    //第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面 ...

随机推荐

  1. POJ1840Eps

    http://poj.org/problem?id=1840 题意 : 有这样一个式子a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0,给你五个系数的值,让你找出x1,x2,x3 ...

  2. Java Socket文件上传

    客户端: import java.io.FileInputStream; import java.net.Socket; /** * Created by 290248126 on 14-5-11. ...

  3. Java传入参数个数不确定可用(Type ... values)

    /** * 可变长的参数. * 有时候,我们传入到方法的参数的个数是不固定的,为了解决这个问题,我们一般采用下面的方法: * 1. 重载,多重载几个方法,尽可能的满足参数的个数.显然这不是什么好办法. ...

  4. redis、memcache、mongoDB有哪些区别(转载)

    转载: http://leandre.cn/database/64.html Memcached Memcached的优点: Memcached可以利用多核优势,单实例吞吐量极高,可以达到几十万QPS ...

  5. Project Euler 95:Amicable chains 亲和数链

    Amicable chains The proper divisors of a number are all the divisors excluding the number itself. Fo ...

  6. JAVA:23种设计模式详解(转)2

    我们接着讨论设计模式,上篇文章我讲完了5种创建型模式,这章开始,我将讲下7种结构型模式:适配器模式.装饰模式.代理模式.外观模式.桥接模式.组合模式.享元模式.其中对象的适配器模式是各种模式的起源,我 ...

  7. C# 常用对象的的修饰符

    class(类) 1.internal 表示类只能在当然程序集中访问,类默认修饰符 2.public 表示所有地方都可以访问,与internal是互斥的 3.abstract 抽象类,不能被实例化,只 ...

  8. 256. Paint House

    题目: There are a row of n houses, each house can be painted with one of the three colors: red, blue o ...

  9. List应用举例

    1.集合的嵌套遍历 学生类: package listexercise; /** * Created by gao on 15-12-9. */ public class Student { priv ...

  10. 常用的coco2d-x游戏开发工具(转)

    物理编辑工具Physics Editing ToolsMekanimo 网址:http://www.mekanimo.net/PhysicsBench 网址:http://www.cocos2d-ip ...