二分答案。

油量越多,显然通过的时间越少。可以二分找到最小的油量,可以在$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. rem自适应js代码

    以后懒得写,直接复制了 var computedFz = (function(){ var designWidth = 375, rem2px = 100; function computedFz() ...

  2. C# 后台获取请求来源、文件下载

    文件流下载文件 void BigFileDownload() { try { string FileName = "测试.docx"; string filePath = Page ...

  3. onCreateView的一个细节--Fragment

    public View onCreateView(LayoutInflater inflater, ViewGroup contaiiner, Bundle savedInstanceState) 在 ...

  4. 【hdu5381】维护区间内所有子区间的gcd之和-线段树

    题意:给定n个数,m个询问,每次询问一个区间内所有连续子区间的gcd的和.n,m<=10^5 题解: 这题和之前比赛的一题很像.我们从小到大枚举r,固定右端点枚举左端点,维护的区间最多只有log ...

  5. Java并发—— 关键字volatile解析

    简述 关键字volatile可以说是Java虚拟机提供的最轻量级的同步机制,当一个变量定义为volatile,它具有内存可见性以及禁止指令重排序两大特性,为了更好地了解volatile关键字,我们可以 ...

  6. react组件之间的几种通信情况

    组件之间的几种通信情况 父组件向子组件通信 子组件向父组件通信 跨级组件通信 没有嵌套关系组件之间的通信 1,父组件向子组件传递 React数据流动是单向的,父组件向子组件通信也是最常见的;父组件通过 ...

  7. mysql 之修改初始密码

    转载自:https://www.cnblogs.com/ivictor/p/5142809.html 为了加强安全性,MySQL5.7为root用户随机生成了一个密码,在error log中,关于er ...

  8. C++之复制控制

    只有单个形参,而且该形参是对本类类型对象的引用(常用const修饰),这样的构造函数叫做复制构造函数(有时也称为拷贝构造函数),例如: class Person{ public: Person();/ ...

  9. 集合类---Map

    Map常用的子类: 一.HashMap详解  1.特点 1)线程不安全.如果想要得到线程安全的HashMap,可以使用Collections的静态方法:Map map = Collections.sy ...

  10. GOLANG编译安装

    GO这个编译器搞的比较混乱,GO本身是汇编+C开发出来的,后来因为觉得自己牛逼,然后用GO语言又写了一次编译器,所以中途抛弃了C,不过这种做法好与不好很难说,go真的这么有自信用自己语言写自己的编译器 ...