Ratings and Reality Shows

参加talk show的时间肯定是在某个t[ i ]的后一秒, 枚举一下就好了。

  1. #include<bits/stdc++.h>
  2. #define LL long long
  3. #define fi first
  4. #define se second
  5. #define mk make_pair
  6. #define PLL pair<LL, LL>
  7. #define PLI pair<LL, int>
  8. #define PII pair<int, int>
  9. #define SZ(x) ((int)x.size())
  10. #define ull unsigned long long
  11.  
  12. using namespace std;
  13.  
  14. const int N = 3e5 + ;
  15. const int inf = 0x3f3f3f3f;
  16. const LL INF = 0x3f3f3f3f3f3f3f3f;
  17. const int mod = ;
  18. const double eps = 1e-;
  19. const double PI = acos(-);
  20.  
  21. int Log[N];
  22. struct ST {
  23. LL dp[N][]; int ty;
  24. void build(int n, LL b[], int _ty) {
  25. ty = _ty;
  26. for(int i = -(Log[]=-); i < N; i++)
  27. Log[i] = Log[i - ] + ((i & (i - )) == );
  28. for(int i = ; i <= n; i++) dp[i][] = ty * b[i];
  29. for(int j = ; j <= Log[n]; j++)
  30. for(int i = ; i+(<<j)- <= n; i++)
  31. dp[i][j] = max(dp[i][j-], dp[i+(<<(j-))][j-]);
  32. }
  33. inline LL query(int x, int y) {
  34. int k = Log[y - x + ];
  35. return ty * max(dp[x][k], dp[y-(<<k)+][k]);
  36. }
  37. };
  38.  
  39. int n, a, b, c, d, start, len;
  40. int t[N], q[N];
  41. LL sum[N];
  42. ST rmq;
  43.  
  44. int main() {
  45. cin >> n >> a >> b >> c >> d >> start >> len;
  46. for(int i = ; i <= n; i++) {
  47. cin >> t[i] >> q[i];
  48. if(q[i]) sum[i] = sum[i - ] + c;
  49. else sum[i] = sum[i - ] - d;
  50. }
  51. t[] = -;
  52. rmq.build(n, sum, -);
  53. LL prefix = start;
  54. int ans = -;
  55. for(int i = ; i <= n; i++) {
  56. if(i) {
  57. if(q[i]) prefix += a;
  58. else prefix -= b;
  59. }
  60. if(prefix < ) break;
  61. int p = lower_bound(t + , t + + n, t[i] + + len) - t - ;
  62. if(p <= i) {
  63. ans = t[i] + ;
  64. break;
  65. } else {
  66. int L = i + , R = p;
  67. LL mn = rmq.query(L, R) - sum[i];
  68. if(prefix + mn >= ) {
  69. ans = t[i] + ;
  70. break;
  71. }
  72. }
  73. }
  74. printf("%d\n", ans);
  75. return ;
  76. }
  77.  
  78. /*
  79. */

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. hue的历史查询记录querys乱码问题解决

    hue的历史查询记录querys乱码问题解决: master1中配置文件/home/hadoop/.versions/hue-3.10.0/desktop/conf/hue.ini 可以看到连接的是m ...

  2. go import 使用方法记录

    import "fmt"      最常用的一种形式 import "./test"   导入同一目录下test包中的内容 import f "fmt ...

  3. 无备份mysql删除表后恢复

    mysql从5.6.17开始自动设置innodb_file_per_table为on,每个表设置单独表空间,数据不是集中存放在ibdata1里.下面测试下无备份后drop表后的恢复. 前奏生成数据字典 ...

  4. CF 313B

    题意: 给你一个字符串, 然后m次区间查询,求出区间有多少组 str[i] == str[i+1] 就是一个水DP了 有则Dp[i] = Dp[i-1] 无则 Dp[i] = Dp[i-1]: (刚开 ...

  5. nginx+ssl 服务器 双向认证

    项目后台服务器采用nginx+tomcat 负载均衡架构  不久 访问协议有http升级为https 对服务器认证采用沃通的ssl证书 nginx ssl证书安装 参照沃通官方文档 他们有技术支持沟通 ...

  6. 《精通Oracle SQL(第2版)》PDF

    一:下载途径 二:图书图样 三:目录 第1章 SQL核心 1.1 SQL语言 1.2 数据库的接口 1.3 SQL*Plus回顾 1.3.1 连接到数据库 1.3.2 配置SQL*Plus环境 1.3 ...

  7. 《深入理解Oracle 12c数据库管理(第二版)》PDF

    一:下载获取位置: 二:本书图样: 三:本书目录: 图书目录: 第1章 安装Oracle 1.1 了解OFA 1.1.1 Oracle清单目录 1.1.2 Oracle基础目录 1.1.3 Oracl ...

  8. python之通过thread来实现多进程

    代码如下: import threading, time class Test1(threading.Thread): def __init__(self, name): super().__init ...

  9. Java的两个实验程序

    日期:2018.10.07 星期五 博客期:015 Part1:----------------第一个是二柱子出30道小学数学题: 一.程序设计思想 本程序设计由三部分构成,第一部分因为循环30次的需 ...

  10. xpath 根据根节点找数据