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为根时,把树边白染色,使得任意点走到根的路径上不超过一条黑 ...
随机推荐
- vue-cli中引入jquery的方法
vue-cli中引入jquery的方法 以前写vue项目都没有引入过jquery,今天群里面的一位小伙伴问了我这个问题,我就自己捣鼓了一下,方法如下: 我们先进入webpack.base.conf.j ...
- CCF-20170901
试题编号: 201709-1 试题名称: 打酱油 时间限制: 1.0s 内存限制: 256.0MB 问题描述 小明带着N元钱去买酱油.酱油10块钱一瓶,商家进行促销,每买3瓶送 ...
- UVA 12716 GCD XOR
https://vjudge.net/problem/UVA-12716 求有多少对整数(a,b)满足:1<=b<=a<=n,且gcd(a,b)=a XOR b 结论:若gcd(a, ...
- LightOJ 1137 - Expanding Rods 基础计算几何
http://www.lightoj.com/volume_showproblem.php?problem=1137 题意:一根长度为L的杆热膨胀为L',左端点到右端点间距离不变,且膨胀后的杆的弧为圆 ...
- java File (文档流)
一. 数据流的基本概念 1.数据流 在Java中把不同的数据源与程序之间的数据传输都抽象表述为“流”(stream),以实现相对统一和简单的输入/输出操作方式.传输中的数据就像流水一样,也称为数据 ...
- 【BZOJ1093】【ZJOI2007】最大半联通子图 [DP][Tarjan]
最大半连通子图 Time Limit: 30 Sec Memory Limit: 162 MB[Submit][Status][Discuss] Description 一个有向图G=(V,E)称为 ...
- 「6月雅礼集训 2017 Day5」学外语
[题目大意] 给出$\{P_i\}$,求经过以下操作后能够得到的不同序列个数: 第一步,选择$i, j$,交换$P_i,P_j$:第二步,把所有$P_x=i$的$P_x$变为$j$,把所有$P_x=j ...
- 【洛谷 P2042】 [NOI2005]维护数列(自闭记第一期)
题目链接 首先,这题我是没A的..太毒瘤了 题目本身不难,都是\(Splay\)的基操,但是细节真的容易挂. 调了好久自闭了,果断放弃.. 希望本节目停更. 放上最终版本 #include <c ...
- PACM Team(牛客第三场多校赛+dp+卡内存+打印路径)
题目链接(貌似未报名的不能进去):https://www.nowcoder.com/acm/contest/141/A 题目: 题意:背包题意,并打印路径. 思路:正常背包思路,不过五维的dp很容易爆 ...
- php中使用static方法
<?php class Char{ public static $number = 0; public static $name; function __construct($what){ se ...