二分答案。

油量越多,显然通过的时间越少。可以二分找到最小的油量,可以在$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的更多相关文章

  1. Codeforces 729C Road to Cinema(二分)

    题目链接 http://codeforces.com/problemset/problem/729/C 题意:n个价格c[i],油量v[i]的汽车,求最便宜的一辆使得能在t时间内到达s,路途中有k个位 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. Road to Cinema

    Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  6. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  7. 【26.83%】【Codeforces Round #380C】Road to Cinema

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. Codeforces 543D. Road Improvement (树dp + 乘法逆元)

    题目链接:http://codeforces.com/contest/543/problem/D 给你一棵树,初始所有的边都是坏的,要你修复若干边.指定一个root,所有的点到root最多只有一个坏边 ...

  9. Codeforces 543D Road Improvement

    http://codeforces.com/contest/543/problem/D 题意: 给定n个点的树 问: 一开始全是黑边,对于以i为根时,把树边白染色,使得任意点走到根的路径上不超过一条黑 ...

随机推荐

  1. js addDays ,addYears

    //添加天 Date.prototype.addDays = function (d) { this.setDate(this.getDate() + d); }; //添加周 Date.protot ...

  2. 知问前端——Ajax登录

    本文,将使用Ajax登录. 一.服务器端代码 is_user.php: <?php require 'config.php'; $query = mysql_query("SELECT ...

  3. java分页通用篇

    一.创建分页通用类 package com.dkyw.util; import java.util.List; public class Page<T> { private int tot ...

  4. web_一些常用的线上脚本地址记录(个人使用)

    1.jquery <script src="http://code.jquery.com/jquery-1.4.1.min.js"></script> 2. ...

  5. Git 常用命令速查表(图文+表格)【转】

    转自:http://www.jb51.net/article/55442.htm 一. Git 常用命令速查 git branch 查看本地所有分支git status 查看当前状态 git comm ...

  6. 64_g2

    gettext-libs-0.19.8.1-9.fc26.x86_64.rpm 15-Mar-2017 14:15 305038 gf2x-1.1-9.fc26.i686.rpm 11-Feb-201 ...

  7. Linux系统编程——进程间通信(System V IPC 对象)

    基本查看命令 ipcs  -m查看共享内存        ipcs -s查看信号量        ipcs -q查看消息队列 ipcrm  -m  id 删除共享内存   -M+key值 ipcrm ...

  8. wifi驱动移植

    目标板:Hi3518 内核版本:linux3.0.8   1.修改makefile #PLATFORM = PC //注释掉 PLATFORM = HI3518 //支持平台 ifeq ($(PLAT ...

  9. FineReport——JS二次开发(下拉框)

    下拉框显示多列时,输入的内容检索的内容为显示值整行数据,而不是实际值. 下拉框选择之后,控件显示的是显示值而非实际值. 对于下拉框显示队列,可以有多种方法,但是经过测试大多数方法不适用,检索效率太低, ...

  10. 我的新博客地址http://xxxbw.github.io/

    最近在学github,在github搭了个博客,以后也会使用另外一个博客.有兴趣的小伙伴可以看看~ 地址:http://xxxbw.github.io/