A11429 | Ratings and Reality Shows
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There are two main kinds of events in the life of top-model: fashion shows and photo shoots. Participating in any of these events affects the rating of appropriate top-model. After each photo shoot model's rating increases by $a$ and after each fashion show decreases by $b$ (designers do too many experiments nowadays). Moreover, sometimes top-models participates in talk shows. After participating in talk show model becomes more popular and increasing of her rating after photo shoots become $c$ and decreasing of her rating after fashion show becomes $d$ .
Izabella wants to participate in a talk show, but she wants to do it in such a way that her rating will never become negative. Help her to find a suitable moment for participating in the talk show.
Let's assume that model's career begins in moment 0. At that moment Izabella's rating was equal to $start$ . If talk show happens in moment $t$ if will affect all events in model's life in interval of time $[t..t+len)$ (including $t$ and not including $t+len$ ), where $len$ is duration of influence.
Izabella wants to participate in a talk show, but she wants to do it in such a way that her rating will not become become negative before talk show or during period of influence of talk show. Help her to find a suitable moment for participating in the talk show.
Izabella wants to participate in a talk show, but she wants to do it in such a way that her rating will never become negative. Help her to find a suitable moment for participating in the talk show.
Let's assume that model's career begins in moment 0. At that moment Izabella's rating was equal to $start$ . If talk show happens in moment $t$ if will affect all events in model's life in interval of time $[t..t+len)$ (including $t$ and not including $t+len$ ), where $len$ is duration of influence.
Izabella wants to participate in a talk show, but she wants to do it in such a way that her rating will not become become negative before talk show or during period of influence of talk show. Help her to find a suitable moment for participating in the talk show.
输入格式
In first line there are 7 positive integers $n$ , $a$ , $b$ , $c$ , $d$ , $start$ , $len$ ( $1<=n<=3·10^{5}$ , $0<=start<=10^{9}$ , $1<=a,b,c,d,len<=10^{9}$ ), where $n$ is a number of fashion shows and photo shoots, $a$ , $b$ , $c$ and $d$ are rating changes described above, $start$ is an initial rating of model and $len$ is a duration of influence of talk show.
In next $n$ lines descriptions of events are given. Each of those lines contains two integers $t_{i}$ and $q_{i}$ ( $1<=t_{i}<=10^{9}$ , $0<=q<=1$ ) — moment, in which event happens and type of this event. Type 0 corresponds to the fashion show and type 1 — to photo shoot.
Events are given in order of increasing $t_{i}$ , all $t_{i}$ are different.
In next $n$ lines descriptions of events are given. Each of those lines contains two integers $t_{i}$ and $q_{i}$ ( $1<=t_{i}<=10^{9}$ , $0<=q<=1$ ) — moment, in which event happens and type of this event. Type 0 corresponds to the fashion show and type 1 — to photo shoot.
Events are given in order of increasing $t_{i}$ , all $t_{i}$ are different.
输出格式
Print one non-negative integer $t$ — the moment of time in which talk show should happen to make Izabella's rating non-negative before talk show and during period of influence of talk show. If there are multiple answers print smallest of them. If there are no such moments, print $-1$ .
输入输出样例
输入 #1
5 1 1 1 4 0 5 1 1 2 1 3 1 4 0 5 0
输出 #1
6
输入 #2
1 1 2 1 2 1 2 1 0
输出 #2
-1
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted