Codeforces 887D Ratings and Reality Shows
参加talk show的时间肯定是在某个t[ i ]的后一秒, 枚举一下就好了。
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long using namespace std; const int N = 3e5 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = ;
const double eps = 1e-;
const double PI = acos(-); int Log[N];
struct ST {
LL dp[N][]; int ty;
void build(int n, LL b[], int _ty) {
ty = _ty;
for(int i = -(Log[]=-); i < N; i++)
Log[i] = Log[i - ] + ((i & (i - )) == );
for(int i = ; i <= n; i++) dp[i][] = ty * b[i];
for(int j = ; j <= Log[n]; j++)
for(int i = ; i+(<<j)- <= n; i++)
dp[i][j] = max(dp[i][j-], dp[i+(<<(j-))][j-]);
}
inline LL query(int x, int y) {
int k = Log[y - x + ];
return ty * max(dp[x][k], dp[y-(<<k)+][k]);
}
}; int n, a, b, c, d, start, len;
int t[N], q[N];
LL sum[N];
ST rmq; int main() {
cin >> n >> a >> b >> c >> d >> start >> len;
for(int i = ; i <= n; i++) {
cin >> t[i] >> q[i];
if(q[i]) sum[i] = sum[i - ] + c;
else sum[i] = sum[i - ] - d;
}
t[] = -;
rmq.build(n, sum, -);
LL prefix = start;
int ans = -;
for(int i = ; i <= n; i++) {
if(i) {
if(q[i]) prefix += a;
else prefix -= b;
}
if(prefix < ) break;
int p = lower_bound(t + , t + + n, t[i] + + len) - t - ;
if(p <= i) {
ans = t[i] + ;
break;
} else {
int L = i + , R = p;
LL mn = rmq.query(L, R) - sum[i];
if(prefix + mn >= ) {
ans = t[i] + ;
break;
}
}
}
printf("%d\n", ans);
return ;
} /*
*/
Codeforces 887D Ratings and Reality Shows的更多相关文章
- 444 D. Ratings and Reality Shows
一个模特有两种活动. ① 拍照片,挣钱 a. ②开演唱会,花费b 给定模特这两种工作的时间表. 模特可以选定一个时间举办一个座谈会,那么他拍照片的钱变c.开演唱会会花费d. 要求在模特座谈会之前和后l ...
- SAE J1850 VPW Implement
---恢复内容开始--- OBDII Interface Project When I can ever find enough time away from schoolwork, I try to ...
- 每日英语:Why 'The Voice' Is China's No. 1 TV Show
U.S. fans of the hit talent show 'The Voice' may take for granted that its judges sit with their bac ...
- Wide-range regulator delivers 12V, 3A output from 16 to 100V source
Synchronous buck regulators offer high efficiency and are popular in applications in which available ...
- codeforces C. New Year Ratings Change 解题报告
题目链接:http://codeforces.com/problemset/problem/379/C 题目意思:有n个users,每个user都有自己想升的rating.要解决的问题是给予每个人不同 ...
- Codeforces 1322D - Reality Show(DP)
Codeforces 题面传送门 & 洛谷题面传送门 首先这个消消乐的顺着消的过程看起来有点难受,DP 起来有点困难.考虑对其进行一个转化:将所有出场的人按照攻击力从小到大合并,然后每次将两个 ...
- Codeforces Round #523 (Div. 2) D. TV Shows 模拟(多重集 先把所有区间加入多重集合)+贪心+二分
题意:给出n个电视节目的起始和结束时间 并且租一台电视需要x +y*(b-a) [a,b]为时段 问完整看完电视节目的最小花费是多少 思路:贪心的思想 情况1 如果新租一台电视的花费<=在空 ...
- Codeforces Round #523 (Div. 2) D. TV Shows
传送门 https://www.cnblogs.com/violet-acmer/p/10005351.html 题意: 有n个节目,每个节目都有个开始时间和结束时间. 定义x,y分别为租电视需要的花 ...
- 【codeforces】【Round#523D】TV shows
题意:n个节目,每个节目的播放时间为[li,ri],你需要选择一些电视机全部播放这些节目,一台电视机不能同时播放多个节目,选择一个新的电视机代价为x , 如果某台电视机的使用时间为[Li,Ri]需要付 ...
随机推荐
- OpenStack实践系列④计算服务Nova
OpenStack实践系列④计算服务Nova 3.6 Nova控制节点的部署创建服务的凭证,完成下列步骤: 创建nova用户,并加入到service项目中,赋予admin权限 [root@node1 ...
- recv() failed (104: Connection reset by peer) while reading response header from upstream
2017年12月1日10:18:34 情景描述: 浏览器执行了一会儿, 报500错误 运行环境: nginx + php-fpm nginx日志: recv() failed (104: Conn ...
- 搭建activemq服务
文章链接:https://www.cnblogs.com/xiaxinggege/p/5900319.html ubuntu下安装JDK并搭建activeMQ 1.安装JDK,网上有人说activ ...
- Redis重大版本
Redis借鉴了Linux操作系统对于版本号的命名规则: 版本号第二位如果是奇数,则为非稳定版本(例如2.7.2.9.3.1),如果是偶数,则为稳定版本(例如2.6.2.8.3.0.3.2), 当前奇 ...
- 2)实现github自动登陆获取信息
# -*- coding:utf-8 -*- # __author__ = 'lixiang' # 实现github自动登陆和获取数据 import requests from bs4 import ...
- Confluence 6 管理协同编辑 - 最大编辑者的限制
我们限制为最多 12 个用户可以同时对一个页面进行编辑.这个意味着当一个页面已经有 12 个用户正在编辑了,13 个用户是不能进入编辑界面的,直到 12 个用户中有一个用户已经离开了. 系统管理员可以 ...
- Nginx详解十四:Nginx场景实践篇之代理服务
代理的作用 Nginx代理 正向代理 反向代理 正向代理和反向代理的区别:代理的对象不一样 正向代理代理的对象是客户端,反向代理代理的对象是服务端 反向代理: 配置语法:proxy_pass URL; ...
- mybatis的插件分析
mybatis插件回在解析配置是通过pluginAll方法将插件添加到插件链中,然后会在sqlSessionfactory.openSession()方法中将插件链绑到executor上,在执行sql ...
- truncate table时存在外键约束的解决办法
以前在使用truncate命令时遇到表存在外键引用时无法执行命令的情况都是用delete来代替,今天又遇到这个问题,于是在网上搜了一把,可以通过如下方式解决: 1.基本思路:先关闭mysql的外键约束 ...
- springcloud Eureka控制台参数说明
Home进入Eureka控制台首页,首先看HOME页的头部 System Status Environment : 环境,默认为test, 该参数在实际使用过程中,可以不用更改 Data center ...