CodeForces 738C Road to Cinema
二分答案。
油量越多,显然通过的时间越少。可以二分找到最小的油量,可以在$t$时间内到达电影院。
一个油箱容量为$v$的车通过长度为$L$的路程需要的最小时间为$max(L,3*L-v)$。计算过程如下:
假设普通速度运行了距离$a$,加速运行了距离$b$,则$a+b=L$,即$b=L-a$。
因为$a+2*b≤v$,所以$a≥2*L-v$。所花时间为$2*a+b≥3*L-v$,因为最小需要$L$的时间,所以取个$max$。按照$max(L,3*L-v)$一段一段加起来验证就可以了。
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<ctime>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0);
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c = getchar();
x = ;
while(!isdigit(c)) c = getchar();
while(isdigit(c))
{
x = x * + c - '';
c = getchar();
}
} struct X
{
long long c,v;
}p[];
int n,k;
long long s,t,g[];
int f[]; bool cmp(X a, X b)
{
return a.v<b.v;
} bool check(long long x)
{
long long tt=;
for(int i=;i<k;i++)
{
long long len=g[i+]-g[i];
tt=tt+max(len,*len-x);
}
if(tt<=t) return ;
return ;
} int main()
{
cin>>n>>k>>s>>t;
for(int i=;i<=n;i++) scanf("%lld%lld",&p[i].c,&p[i].v);
for(int i=;i<=k;i++)scanf("%lld",&g[i]); g[]=; g[k+]=s; k++;
sort(g,g++k);
sort(p+,p++n,cmp); long long mxlen=g[]-g[];
for(int i=;i<=k-;i++)
{
long long len=g[i+]-g[i];
mxlen=max(mxlen,len);
} long long INF=0x7FFFFFFF; INF=INF*INF; long long L=mxlen,R=,limit=-; while(L<=R)
{
long long mid=(L+R)/;
if(check(mid)) limit=mid,R=mid-;
else L=mid+;
} if(limit==-) printf("-1\n");
else
{
long long mn=INF;
for(int i=;i<=n;i++)
{
if(p[i].v<limit) continue;
mn=min(mn,p[i].c);
}
if(mn==INF) printf("-1\n");
else printf("%lld\n",mn);
} return ;
}
CodeForces 738C Road to Cinema的更多相关文章
- Codeforces 729C Road to Cinema(二分)
题目链接 http://codeforces.com/problemset/problem/729/C 题意:n个价格c[i],油量v[i]的汽车,求最便宜的一辆使得能在t时间内到达s,路途中有k个位 ...
- Codeforces #380 div2 C(729C) Road to Cinema
C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2)C. Road to Cinema 二分
C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Technocup 2017 - Elimination Round 2 C. Road to Cinema —— 二分
题目链接:http://codeforces.com/problemset/problem/729/C C. Road to Cinema time limit per test 1 second m ...
- Road to Cinema
Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【26.83%】【Codeforces Round #380C】Road to Cinema
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces 543D. Road Improvement (树dp + 乘法逆元)
题目链接:http://codeforces.com/contest/543/problem/D 给你一棵树,初始所有的边都是坏的,要你修复若干边.指定一个root,所有的点到root最多只有一个坏边 ...
- Codeforces 543D Road Improvement
http://codeforces.com/contest/543/problem/D 题意: 给定n个点的树 问: 一开始全是黑边,对于以i为根时,把树边白染色,使得任意点走到根的路径上不超过一条黑 ...
随机推荐
- 消除float浮动的影响
一. 在父元素中当前浮动元素下面添加一个空的div 添加clear属性 <div style="displya:none;clear: left;"></div& ...
- [洛谷P3761] [TJOI2017]城市
洛谷题目链接:[TJOI2017]城市 题目描述 从加里敦大学城市规划专业毕业的小明来到了一个地区城市规划局工作.这个地区一共有ri座城市,<-1条高速公路,保证了任意两运城市之间都可以通过高速 ...
- MyBatis框架的使用及源码分析(十三) ResultSetHandler
在PreparedStatementHandler中的query()方法中,用ResultSetHandler来完成结果集的映射. public <E> List<E> que ...
- 基于 Docker 的 Zabbix 微服务系统
zabbix 官网提供一个镜像 [ zabbix-appliance ], 可以直接拉起一个 zabbix-server. 但是数据库无法分离出来. 本实践使用 zabbix 官方提供的 Docker ...
- TDD随想录
TDD随想录 谨以本文献给TDD的开创者与传播者 本文纯属个人经历,如有雷同纯属巧合 我从不觉得自己是一个好的程序员,甚至可能连合格都谈不上,不过在内心深处我却渴望着在编程这件事上获得成功. 可惜每次 ...
- LCD实验学习笔记(七):NAND FLASH
s3c2440 CPU内置NAND FLASH控制器.相关寄存大器起始地址为0x4e000000. 通过设置NFCONF寄存器,设置NAND FLASH 时序. 通过设置NFCONT寄存器,使能NAN ...
- 分布式队列Celery
Celery是什么? Celery 是一个由 Python 编写的简单.灵活.可靠的用来处理大量信息的分布式系统,它同时提供操作和维护分布式系统所需的工具. Celery 专注于实时任务处理,支持任务 ...
- SD卡 模拟SPI总线控制流程
SD卡为移动设备提供了安全的,大容量存储解决方法.它本身可以通过两种总线模式和MCU进行数据传输,一种是称为SD BUS的4位串行数据模式,另一种就是大家熟知的4线SPI Bus模式.一些廉价,低端的 ...
- 【转】C++多继承的细节
这几天写的程序应用到多继承. 以前对多继承的概念非常清晰,可是很久没用就有点模糊了.重新研究一下,“刷新”下记忆. 假设我们有下面的代码: #include <stdio.h> class ...
- python基础===中文手册,可查询各个模块
http://python.usyiyi.cn/translate/python_352/index.html