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. centos 专题-各种配置应有尽有

    你想要的在这里都能得到解决: http://www.linuxidc.com/topicnews.aspx?tid=14

  2. js数组之可变函数

    在js的数组中有两个方法为数组添加元素:1.push();2.unshift(),push函数是将元素添加到数组的末尾,现在不用说大家估计也能猜出来,unshift这个函数就是把元素添加到数组的开头的 ...

  3. AOAPC I: Beginning Algorithm Contests (Rujia Liu) Volume 6. Mathematical Concepts and Methods

    uva 106 这题说的是 说计算 x^2 + y^2  =  z^2  xyz 互质 然后计算个数和 在 N内 不在 勾股数之内的数的个数 然后去找需要的 维基百科上 看到 另 n*m*2 =b   ...

  4. OS X 下动态库的引用

    foo.c #include <stdio.h> void foo(void) { printf("foo.\n"); } main.c #include <st ...

  5. mysql错误日志与通用日志

    错误日志 MySQL错误日志是记录MySQL 运行过程中较为严重的警告和错误信息,以及MySQL每次启动和关闭的详细信息. 1.错误日志路径查询 show variables like '%log_e ...

  6. 学写网页 #04# w3school

    索引: HTML 输入类型 XHTML HTML5 HTML5 样式指南和代码约定 WHO 成立于 1948 年. 对缩写进行标记能够为浏览器.翻译系统以及搜索引擎提供有用的信息. code 元素不保 ...

  7. 浏览器内核、排版引擎、js引擎

    [定义] 浏览器最重要或者说核心的部分是“Rendering Engine”,可大概译为“渲染引擎”,不过我们一般习惯将之称为“浏览器内核”.负责对网页语法的解释(如标准通用标记语 言下的一个应用HT ...

  8. 02: Redis缓存系统

    目录: 1.1 在centos6.5中安装Redis 1.2 Redis的简介及两种基本操作 1.3 Redis对string操作(第一类) 1.4 redis对Hash操作,字典格式(第二类) 1. ...

  9. 20145216史婧瑶《网络对抗》Web基础

    20145216史婧瑶<网络对抗>Web基础 实验问题回答 (1)什么是表单 表单在网页中主要负责数据采集功能.一个表单有三个基本组成部分: 表单标签.表单域.表单按钮. (2)浏览器可以 ...

  10. 在EditText里输入小写字母时,将小写字母转化为大写显示

    1.新建类继承ReplacementTransformationMethod 方法 public class test extends ReplacementTransformationMethod ...