832C - Strange Radiation

思路:二分最短时间。

代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define pii pair<int,int>
#define pil pair<int,long>
#define mem(a,b) mamset(a,b,sizeof(a)) const int MOD=1e9+;
const int INF=0x3f3f3f3f;
const int N=1e5+;
const double eps=1e-; int n;
double s; struct people
{
double x,v,t;
}a[N]; bool check(double t)
{
bool flag1=false,flag2=false;
double l_l=1e6,l_r=,r_l=1e6,r_r=;
for(int i=;i<n;i++)
{
if(a[i].t==)
{
if(a[i].x-(a[i].v+s)*t>)continue;//如果炸弹放在这个点上都到不了,说明这个人肯定到不了。
flag1=true;
if(a[i].x-a[i].v*t<=)//如果不加速也能到,那说明炸弹放在哪里都可以。
{
l_l=;
l_r=1e6;
continue;
}
double X=floor((t*(s*s-a[i].v*a[i].v)+a[i].x*a[i].v)/s);
l_r=max(l_r,X);//取并集
l_l=min(l_l,(double)a[i].x);
}
else if(a[i].t==)
{
if(a[i].x+(a[i].v+s)*t<1e6)continue;
flag2=true;
if(a[i].x+a[i].v*t>=1e6)
{
r_l=;
r_r=1e6;
continue;
}
double X=ceil((1e6*(s-a[i].v)-t*(s*s-a[i].v*a[i].v)+a[i].x*a[i].v)/s);
r_l=min(r_l,X);
r_r=max(r_r,(double)a[i].x);
}
}
if(!flag1||!flag2)return false;
if(l_l>l_r||r_l>r_r)return false;
if(l_r<r_l||r_r<l_l)return false;//取交集
return true;
} int main()
{
scanf("%d%lf",&n,&s);
for(int i=;i<n;i++)
scanf("%lf%lf%lf",&a[i].x,&a[i].v,&a[i].t); double l=,r=1e6+;
double mid=(l+r)/;
while(r-l>=eps)
{
if(check(mid))r=mid;
else l=mid;
mid=(l+r)/;
}
printf("%.12lf\n",mid);
return ;
}

Codeforces 832C - Strange Radiation的更多相关文章

  1. Codeforces Round #425 (Div. 2) C - Strange Radiation

    地址:http://codeforces.com/contest/832/problem/C 题目: C. Strange Radiation time limit per test 3 second ...

  2. Codeforces Round #425 (Div. 2) Problem C Strange Radiation (Codeforces 832C) - 二分答案 - 数论

    n people are standing on a coordinate axis in points with positive integer coordinates strictly less ...

  3. codeforces A. Strange Addition 解题报告

    题目链接:http://codeforces.com/problemset/problem/305/A 题目意思:给出一个序列,需要从中选择一些数,这些数需要满足:任意的两个数中每一位至少有一个数满足 ...

  4. Codeforces 1383E - Strange Operation(线段树优化 DP or 单调栈+DP)

    Codeforces 题目传送门 & 洛谷题目传送门 Yet another 自己搞出来的难度 \(\ge 2800\) 的题 介绍一个奇奇怪怪的 \(n\log n\) 的做法.首先特判掉字 ...

  5. codeforces 484C Strange Sorting Codeforces Round #276 (Div. 1) C

    思路:首先 他是对1到k 元素做一次变换,然后对2到k+1个元素做一次变化....依次做完. 如果我们对1到k个元素做完一次变换后,把整个数组循环左移一个.那么第二次还是对1 到 k个元素做和第一次一 ...

  6. codeforces 873C - Strange Game On Matrix

    题目大意:给你一个n*m的只有0和1的矩阵,找到每列第一个1的位置a[i][j],a[i][j]及其a[min(k,n-i+1][j]中1的数量,每列位置值是1的可以变为0: 解题思路:因为数据较小, ...

  7. Codeforces Round #425 (Div. 2)C

    题目连接:http://codeforces.com/contest/832/problem/C C. Strange Radiation time limit per test 3 seconds ...

  8. Codeforces Round #373 (Div. 2) C. Efim and Strange Grade 水题

    C. Efim and Strange Grade 题目连接: http://codeforces.com/contest/719/problem/C Description Efim just re ...

  9. Codeforces Round #373 (Div. 2) C. Efim and Strange Grade —— 贪心 + 字符串处理

    题目链接:http://codeforces.com/problemset/problem/719/C C. Efim and Strange Grade time limit per test 1 ...

随机推荐

  1. 自实现jQuery版分页插件

    本篇博客的分页插件是在2017-11-10 的一篇博客的基础上改造的(原博客地址:原生js版分页插件),主要是优化了分页按钮的排列和显示样式,取消首页和末页的箭头按钮,改为数字按钮,并始终把它们分别固 ...

  2. 错误:Python Urlfetch Error:'GET

    1) 如果你初装了 GaAgent, 记得把在 proxy.ini 里的 id 填上:2) 刷新几次:3) 把浏览器关了,重新打开:4) 清除浏览器的缓冲区:5) 清除 cookies6) 用浏览器的 ...

  3. 关于安装VS2010过程中的错误

    下午本来安装好了VS:但是后来由于自己更新太多功能:直接使得VS太卡打不开:卸载重装:但是卸载的时候在“开始”里面的帮助文档和一些目录在卸载项里面没有:而在“开始"菜单就有:所以我索性把整个 ...

  4. I/O复习

    I/O流之字符流 问题:字节流和字符流区别? java1.0只提供了字节流,分为输出流(Inputstream)和输入流(Outputstream), 以字节为单位来读取或写入数据,以二进制来处理数据 ...

  5. SNMP学习笔记之Centos7配置SNMP服务

    0x00 安装yum源安装SNMP软件包 1.yum源安装SNMP服务: yum -y install net-snmp net-snmp-utils 2.查看SNMP版本号: snmpd -v 0x ...

  6. 开发代码code中变量替换

    除了automake/autoconfig 之外,还有其他的替换方式. 参看vdsm https://github.com/oVirt/vdsm/blob/master/Makefile.am htt ...

  7. switch to hexo !

    用 hexo 搭了个博客 但是由于本博客内容过多,所以对于少数内容搬迁,而且本博客和那个博客相关联,但是这个博客不再更新. 新站地址 再见!

  8. 20145106《Java程序设计》第7周学习总结

    教材学习内容总结 使用Lambda的特性可以去除重复的信息,以取得语法的简洁,增加程序代码的表达性.Lambda表达式本身是中性的,不代表任何类型的实例,同样的Lambda表达式,可用来表示不同目标类 ...

  9. 20145322何志威 Exp8 Web基础

    20145322何志威 Exp8 Web基础 实践过程记录 一.Apache 1 修改/etc/apache2/ports.conf里的端口为5322后重新开启: 2 可以在浏览器中输入localho ...

  10. android 通过webview调起支付宝app支付

    网站学习:http://blog.csdn.net/zhuyu19911016520/article/details/71763900