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的更多相关文章

  1. 444 D. Ratings and Reality Shows

    一个模特有两种活动. ① 拍照片,挣钱 a. ②开演唱会,花费b 给定模特这两种工作的时间表. 模特可以选定一个时间举办一个座谈会,那么他拍照片的钱变c.开演唱会会花费d. 要求在模特座谈会之前和后l ...

  2. SAE J1850 VPW Implement

    ---恢复内容开始--- OBDII Interface Project When I can ever find enough time away from schoolwork, I try to ...

  3. 每日英语: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 ...

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

  5. codeforces C. New Year Ratings Change 解题报告

    题目链接:http://codeforces.com/problemset/problem/379/C 题目意思:有n个users,每个user都有自己想升的rating.要解决的问题是给予每个人不同 ...

  6. Codeforces 1322D - Reality Show(DP)

    Codeforces 题面传送门 & 洛谷题面传送门 首先这个消消乐的顺着消的过程看起来有点难受,DP 起来有点困难.考虑对其进行一个转化:将所有出场的人按照攻击力从小到大合并,然后每次将两个 ...

  7. Codeforces Round #523 (Div. 2) D. TV Shows 模拟(多重集 先把所有区间加入多重集合)+贪心+二分

    题意:给出n个电视节目的起始和结束时间  并且租一台电视需要x +y*(b-a)  [a,b]为时段 问完整看完电视节目的最小花费是多少 思路:贪心的思想 情况1 如果新租一台电视的花费<=在空 ...

  8. Codeforces Round #523 (Div. 2) D. TV Shows

    传送门 https://www.cnblogs.com/violet-acmer/p/10005351.html 题意: 有n个节目,每个节目都有个开始时间和结束时间. 定义x,y分别为租电视需要的花 ...

  9. 【codeforces】【Round#523D】TV shows

    题意:n个节目,每个节目的播放时间为[li,ri],你需要选择一些电视机全部播放这些节目,一台电视机不能同时播放多个节目,选择一个新的电视机代价为x , 如果某台电视机的使用时间为[Li,Ri]需要付 ...

随机推荐

  1. Ubuntu解除"输入密码以解锁密钥环”

    解决办法有两种: 1.去掉默认密钥环的密码: 打开应用程序->附件->密码和加密密钥(如果你的没有,在终端中输入 seahorse),切换到密码选项卡,会看到一个密码密钥环(我的密钥环是 ...

  2. 面向对象(metaclass继承高级用法)

    方法一:# class MyType(type):# def __init__(self,*args,**kwargs):# print('132')# super(MyType,self).__in ...

  3. iOS10 远程通知需要有entitlements的支持

    今天测试远程通知,发现ios9上可以收到,但是ios10上无法收到,原来是忘记开下面这个选项了: 这样看来iOS9 对这个entitlement没有什么依赖,但是10却是必须打开的!

  4. php array_map与array_walk使用对比

    array_map(): 1.array_map() 函数将用户自定义函数作用到数组中的每个值上,并返回用户自定义函数作用后的带有新值的数组,若函数作用后无返回值,则对应的新值数组中为空. 2.回调函 ...

  5. python之__call__()

    __call__ 在Python中,函数其实是一个对象: >>> f = abs >>> f.__name__ 'abs' >>> f(-123) ...

  6. js——prototype、__proto__、constructor

                                       Object                                    1. Object是一个函数(typeof O ...

  7. 信息摘要算法之七:SHA在区块链中的应用

    最近几年比特币的火爆带动了人们对区块链技术的研究.当然我们在这里并不讨论区块链技术本身,而是讨论一下区块链中的SHA算法的应用.对于SHA系列算法我们已经在前面作了说明,在这里也不再重复. 1.区块链 ...

  8. Confluence 6 找到在创建 XML 备份的时候出现的错误

    错误可能是因为数据库突然不可访问而产生.如果你在你的日志中看到了错误  'Couldn't backup database data' ,这个指南将会帮助你更正这个错误.我们强烈推荐你备份 Confl ...

  9. Confluence 6 H2 数据库连接与合并整合

    使用 H2 console 连接到你嵌入的 H2 数据库 可以选的,你可以使用 H2 console 来连接到你的 H2 数据库.最简单的访问 Console 的方法是双击 H2 数据库的 jar 文 ...

  10. Confluence 6 找到你的支持识别代码(SEN)

    你可以在下面 3 个地方找到你的 SEN 代码: 在 Confluence 中,进入  > 基本配置(General Configuration) > 许可证详细(License Deta ...