一个模特有两种活动。

① 拍照片,挣钱 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. 山东理工大学SDUT - ACM OJ 题: Python代码 及分析

    Python基础语法学习完成,先刷基础题100道巩固 ,附 题目.代码.知识分析 题目:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index ...

  2. 「Android」GreenDao

    译文 版本:greenDAO 3.2.2 官网:http://greenrobot.org/greendao/ GitHub:https://github.com/greenrobot/greenDA ...

  3. git 入门教程之备忘录[译]

    备忘录[译] 创建 | Create 克隆一个已存在的仓库 | Clone an existing repository git clone git@github.com:snowdreams1006 ...

  4. Using IntelliJ IDEA as the Vim Editor

    转载自https://www.jetbrains.com/help/idea/using-intellij-idea-as-the-vim-editor.html This feature is on ...

  5. SQL server分离和附加数据库

    下文是参考网友的文章结合自身的经验来总结的 应用于将数据库更改到同一计算机或不同计算机的不同SQL server实例中,或者要移动数据库文件存储的位置时. 一.分离数据库 将数据库从SQL serve ...

  6. SQL Server -- 回忆笔记(一):初见数据库

    SQL Server知识点回忆篇(一):初见数据库 1.  主键 primary key    唯一标识, 不会重复的值才会用来当做主键使用. 表可以没有主键,但建议每张表都有主键. 2.  数据冗余 ...

  7. MongoDB启动文件配置参数详解

    接手的MongoDB只有一个日志文件,体积非常大,排错不便.在找解决办法的时候发现MongoDB的启动文件配置项超级多,于是产生了解释配置参数的想法. mongod服务有两种启动方式 一种是通过配置文 ...

  8. ASP.NET MVC从视图传参到控制器的几种形式

    1. 传递数组 $(function () { var value = ["C#", "JAVA", "PHP"]; $("inp ...

  9. Solidity高级理论(二):Gas

    solidity高级理论(二):Gas 关键字:Gas.结构体.节省小技巧 Gas是什么 在Solidity中,用户想要执行DApp都需要支付一定量的Gas,Gas可以用以太币购买,所以,用户每次使用 ...

  10. vscode中配置php的xdebug

    vscode中配置php的xdebug vscode配置php的xdebug,步骤如下: 1. 安装phpdebug插件: PHP Debug 2.网上下载php的xdebug扩展(注意根据自己的ph ...