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为根时,把树边白染色,使得任意点走到根的路径上不超过一条黑 ...
随机推荐
- LightOJ 1226 - One Unit Machine Lucas/组合数取模
题意:按要求完成n个任务,每个任务必须进行a[i]次才算完成,且按要求,第i个任务必须在大于i任务完成之前完成,问有多少种完成顺序的组合.(n<=1000 a[i] <= 1e6 mod ...
- hdu5828 Rikka with Sequence
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5828 [题解] 考虑bzoj3211 花神游历各国,只是多了区间加操作. 考虑上题写法,区间全为1打标记 ...
- PAT L1-009 N个数求和(运用GCD进行通分)
题目链接:https://www.patest.cn/contests/gplt/L1-009 题目: 本题的要求很简单,就是求N个数字的和.麻烦的是,这些数字是以有理数“分子/分母”的形式给出的,你 ...
- 表格td内容超出宽度显示... table-layout: fixed;
td宽度用百分比固定好的时候,即使设置了 white-space:nowrap;/*文本不会换行,在同一行显示*/ overflow:hidden;超出隐藏 text-overflow:ellipsi ...
- ”未能加载文件或程序集“Oracle.DataAccess”或它的某一个依赖项
引用:http://www.cnblogs.com/joey0210/archive/2012/09/29/2708420.html 上一篇文章说到了DLL引用问题,主要是说的程序中如果使用过了反射, ...
- Select 使用不当引发的core,你应该知道的
排查一个死机问题,搞了好几天时间,最终确定原因:最终确定问题原因,在此分享一下: 第一步:常规根据core文件查看栈信息,gdb –c core xxxx 如下rip不正确,指令地址错乱,栈信息已破坏 ...
- eclipse执行maven install命令时跳过test
在pom.xml里面配置一下代码,将跳过test. <plugins> <plugin> <groupId>org.apache.maven.plugins< ...
- python基础===【字符串】所有相关操作
#字符串的相关操作 #基本操作 #+ 字符串连接操作 str1 = '来是come走是go' str2 = '点头yes摇头no' result = str1 + str2 print(result) ...
- ZZ:Solaris 10 软件包分析
ZZ:Solaris 10 软件包分析 http://blog.chinaunix.net/uid-22759617-id-276756.html # Last updated: 2006-02-14 ...
- delphi2006语言新特性:Record类型高级用法
delphi语言在传统的Records类型的基础上增加了许多像类一样的高级功能,如:Records可以有属性和方法(包括构造constructors),类属性,类方法,类静态字段和内嵌类型.下面这个示 ...