A9365 | Watching Fireworks is Fun
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
A festival will be held in a town's main street. There are $n$ sections in the main street. The sections are numbered $1$ through $n$ from left to right. The distance between each adjacent sections is $1$ .
In the festival $m$ fireworks will be launched. The $i$ -th ( $1<=i<=m$ ) launching is on time $t_{i}$ at section $a_{i}$ . If you are at section $x$ ( $1<=x<=n$ ) at the time of $i$ -th launching, you'll gain happiness value $b_{i}-|a_{i}-x|$ (note that the happiness value might be a negative value).
You can move up to $d$ length units in a unit time interval, but it's prohibited to go out of the main street. Also you can be in an arbitrary section at initial time moment (time equals to $1$ ), and want to maximize the sum of happiness that can be gained from watching fireworks. Find the maximum total happiness.
Note that two or more fireworks can be launched at the same time.
In the festival $m$ fireworks will be launched. The $i$ -th ( $1<=i<=m$ ) launching is on time $t_{i}$ at section $a_{i}$ . If you are at section $x$ ( $1<=x<=n$ ) at the time of $i$ -th launching, you'll gain happiness value $b_{i}-|a_{i}-x|$ (note that the happiness value might be a negative value).
You can move up to $d$ length units in a unit time interval, but it's prohibited to go out of the main street. Also you can be in an arbitrary section at initial time moment (time equals to $1$ ), and want to maximize the sum of happiness that can be gained from watching fireworks. Find the maximum total happiness.
Note that two or more fireworks can be launched at the same time.
输入格式
The first line contains three integers $n$ , $m$ , $d$ ( $1<=n<=150000; 1<=m<=300; 1<=d<=n$ ).
Each of the next $m$ lines contains integers $a_{i}$ , $b_{i}$ , $t_{i}$ ( $1<=a_{i}<=n; 1<=b_{i}<=10^{9}; 1<=t_{i}<=10^{9}$ ). The $i$ -th line contains description of the $i$ -th launching.
It is guaranteed that the condition $t_{i}<=t_{i+1}$ ( $1<=i<m$ ) will be satisfied.
Each of the next $m$ lines contains integers $a_{i}$ , $b_{i}$ , $t_{i}$ ( $1<=a_{i}<=n; 1<=b_{i}<=10^{9}; 1<=t_{i}<=10^{9}$ ). The $i$ -th line contains description of the $i$ -th launching.
It is guaranteed that the condition $t_{i}<=t_{i+1}$ ( $1<=i<m$ ) will be satisfied.
输出格式
Print a single integer — the maximum sum of happiness that you can gain from watching all the fireworks.
Please, do not write the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
Please, do not write the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
输入输出样例
输入 #1
50 3 1 49 1 1 26 1 4 6 1 10
输出 #1
-31
输入 #2
10 2 1 1 1000 4 9 1000 4
输出 #2
1992
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted