一个模特有两种活动。

① 拍照片,挣钱 a。 ②开演唱会,花费b

给定模特这两种工作的时间表。

模特可以选定一个时间举办一个座谈会,那么他拍照片的钱变c。开演唱会会花费d。

要求在模特座谈会之前和后len天(当天凌晨即可生效) 都不能赔钱。 要求你输出最小的座谈会天数。 没有输出-1.。

ll n, a, b, c, d, st, len;
struct node
{
ll tim, tp;
} p[N];
ll calc1(ll x)
{
if(x==-1)
return 0;
return x ? a : -b;
}
ll calc2(ll x)
{
return x ? c : -d;
}
ll tail = 0;
ll mi = inf;
ll res = 0;
ll sum = 0;
int main()
{
sdf(n), sdf(a), sdf(b), sdf(c), sdf(d), sdf(st), sdf(len);
p[0].tim = -1, p[0].tp = -1;
p[n + 1].tim = 1e18;//这里开大点,0x3f3f3f3f不够
For(i, 1, n)
sdf(p[i].tim),
sdf(p[i].tp);
For(i, 0, n)
{
sum += calc1(p[i].tp);
if (sum < -st)
{
cout << -1;
return 0;
}
while (p[tail + 1].tim <= p[i].tim + len)
{
++tail, res += calc2(p[tail].tp);
chkmin(mi, res);
}
if (sum + mi >= -st)
{
cout << p[i].tim + 1;
return 0;
}
mi -= calc2(p[i + 1].tp);
res -= calc2(p[i + 1].tp);
}
return 0;
}

444 D. Ratings and Reality Shows的更多相关文章

  1. Codeforces 887D Ratings and Reality Shows

    Ratings and Reality Shows 参加talk show的时间肯定是在某个t[ i ]的后一秒, 枚举一下就好了. #include<bits/stdc++.h> #de ...

  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. ARVE: Augmented Reality Applications in Vehicle to Edge Networks

    ARVE:车辆到边缘网中的增强现实应用 本文为SIGCOMM 2018 Workshop (Mobile Edge Communications, MECOMM)论文. 笔者翻译了该论文.由于时间仓促 ...

  6. 每日英语:Three Shows That Changed The Way Networks Think About Viewership

    As we continue examining this season’s DVR success stories in The Blacklist and Sleepy Hollow it mak ...

  7. 每日英语:Stalled Project Shows Why China's Economy Is Wobbling

    CAOFEIDIAN, China  $91 billion industrial project here, mired in debt and unfulfilled promise, sugge ...

  8. VR ( Virtual Reality )、AR(Augmented Reality)、MR(Mix Reality)和CR(Cinematic Reality)是什么鬼?

    整个社会对虚拟现实的研究和开发源于上个世纪六十年代,计算机图形学.人机接口技术.图像处理与模式识别.多传感技术.语音处理与音响技术.高性能计算机系统.人工智能等领域在之后半个世纪取得了长足的发展为虚拟 ...

  9. 如何透过HTC Vive拍摄Mixed Reality (混合现实)影片

    https://www.vive.com/cn/forum/1706?extra=page%3D1 也许你是一位开发者,想为自己的HTC Vive游戏制作酷炫的宣传片:或者你是游戏主播,想为观众带来高 ...

随机推荐

  1. 9.Odoo产品分析 (二) – 商业板块(4) –讨论(1)

    查看Odoo产品分析系列--目录 讨论模块就是一个信息记录和消息提醒的功能,在登录到odoo平台的时候第一个界面就是它:  1. 收件箱 收件箱,登录者的邮箱管理,并显示未读邮件数量:    点击上面 ...

  2. git 代码服务器的网页版gitweb的搭建

    sudo apt-get install apache2 git-core gitwebsudo a2enmod rewrite #vi /etc/gitweb.conf $projectroot = ...

  3. ajax请求经典格式

    $.ajax({ url: url, type: "POST", dataType: "json", data: data, success: funtion1 ...

  4. SQL中常用系统函数

    --1 CONVERT(数据类型,表达式),CAST( 表达式 AS 数据类型) 转变数据类型--将数字转化为字符串SELECT CONVERT(varchar(2),12)+CONVERT(varc ...

  5. 加密webconfig中的连接字符串,利用RSA非对称加密,利用windows保存密钥容器

    简单的解决方法: WebConfig 加解密,未能使用提供程序“RsaProtectedConfigurationProvider”进行解密.提供程序返回错误消息为: 打不开 RSA 密钥容器.问题: ...

  6. Cas 服务器 Service(Cas客户端)注册信息维护

    作为Cas服务器,允许哪些客户端接入与否是通过配置来定义的.对Cas服务器来说,每一个接入的客户端与一个Service配置对应:在Cas服务器启动时加载并注册上这些Service,与之对应的客户端才能 ...

  7. ZooKeeper使用命令大全

    stat path [watch]    set path data [version]    ls path [watch]    delquota [-n|-b] path    ls2 path ...

  8. Node 各个版本支持ES2015特性的网站

    如果想了解Node 各个版本支持ES2015到那个程度,可以看下面网站. https://node.green/

  9. [Hive_6] Hive 的内置函数应用

    0. 说明 Hive 的内置函数的基本操作 | 时间函数 | String 函数 | 条件语句 | explode | split | substring 1. 基本操作 查看函数 show func ...

  10. LeetCode算法题-Longest Palindrome(五种解法)

    这是悦乐书的第220次更新,第232篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第87题(顺位题号是409).给定一个由小写或大写字母组成的字符串,找到可以用这些字母构 ...