HEU The message
囧啊,读错题了,一直在想为什么是DP。误以为当时间相同是可以一起删除。后来发现并非如此。用ans[i]记录前i条信息全部删除的最短时间,dele[i][i]表示删除第i条信息所需的时间,opt[a][b]是从a到b一起删除的时候所需的时间。用结构体表示 到达时间 ( arr ),删除所需时间(cost )。
转移方程为 cnt = max ( ans[j], mess[i].arr ) + opt[j + 1][i] , ans[i] = min ( ans[i], cnt ) ( 0 <= j < i )
#include <cstdio>
#include <cstring>
#include <algorithm>
const int MAXX = 1 << 29;
using namespace std;struct Mess {int arr, cost;
}mess[505];int Case, ans[505], opt[505][505], m[505][505], l[505][505];void init ( ) {for ( int i = 1; i <= Case; ++i ) {l[i][i] = m[i][i] = opt[i][i] = mess[i].cost;ans[i] = MAXX;}for ( int i = 1; i < Case; ++i ) {for ( int j = i + 1; j <= Case; ++j ) {l[i][j] = min ( l[i][j - 1], mess[j].cost );m[i][j] = max ( m[i][j - 1], mess[j].cost );opt[i][j] = m[i][j] + l[i][j];}}
}void dp ( ) {init ( );for ( int i = 1; i <= Case; ++i )for ( int j = 0; j < i; ++j )if ( ans[i] >= max ( ans[j], mess[i].arr ) + opt[j + 1][i] ) ans[i] = max ( ans[j], mess[i].arr ) + opt[j + 1][i];
}bool cmp ( Mess a, Mess b ) {return a.arr < b.arr;
}int main ( ) {while ( scanf ( "%d", &Case ) != EOF ) {for ( int i = 1; i <= Case; ++i )scanf ( "%d%d", &mess[i].arr, &mess[i].cost );sort ( mess + 1, mess + Case + 1, cmp );dp ( );printf ( "%d\n", ans[Case] );}
}
HEU The message相关推荐
- 规范的 Commit Message
在 Angular 规范中,Commit Message 包含三个部分,分别是 Header.Body 和 Footer,格式如下: <type>[optional scope]: < ...
- Setting the Reply-To Header in an Email using CDONTS.NewMail Object and CDO Message
代码 1 <% 2 Option Explicit 3 4 Dim objMail 5 Dim strSubject 6 Dim strBody 7 8 strSubject ...
- EMQ学习笔记---Clean Session和Retained Message
MQTT会话(Clean Session) MQTT客户端向服务器发起CONNECT请求时,可以通过'Clean Session'标志设置会话. 'Clean Session'设置为0,表示创建一个持 ...
- Message、Handler、Message Queue、Looper之间的关系
2019独角兽企业重金招聘Python工程师标准>>> 在单线程模型下,为了解决线程通信问题,Android设计了一个通信机制.Message Queue(消息队列), 线程间的通信 ...
- CAS (10) —— JBoss EAP 6.4下部署CAS时出现错误exception.message=Error decoding flow execution的解决办法...
CAS (10) -- JBoss EAP 6.4下部署CAS时出现错误exception.message=Error decoding flow execution的解决办法 jboss版本: jb ...
- 使用alterMIME实现添加message footer功能
1. 安装alterMIME tar zxvf altermime-0.3.8.tar.gz cd altermin3-0.3.8 make make install alterm ...
- Selenium 爬虫时遇到的问题 Selenium message:session not created
出现问题如下: Selenium message:session not created: This version of ChromeDriver only supports Chrome vers ...
- Warning message:NAs introduced by coercion
Warning message:NAs introduced by coercion 目录 Warning message:NAs introduced by coercion 问题: 解决: 完整问 ...
- Warning message:In a + b : longer object length is not a multiple of shorter object length
Warning message:In a + b : longer object length is not a multiple of shorter object length 目录 Warnin ...
最新文章
- 虚幻引擎5:从零开始的蓝图近战AI学习教程
- 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接
- hdu4614 Vases and Flowers 线段树+二分
- 简单一码付:将支付宝和微信的收款二维码合并为一个二维码
- 堪比熊猫烧香!中国新型蠕虫病毒大爆发!电脑瞬间报废
- 猴年猴赛雷,曙光服务器全面升级E5-v4平台
- Apriori算法——中医病症辩证关联规则分析
- 三极管工作原理分析,精辟、透彻
- Oracle - 索引
- 游戏精细化营销不靠买量 获客也能踩着夏天的西瓜皮直线上升!
- cordova build android 出错问题汇总
- pytorch镜像安装【清华源】
- pyqt5 QPainter绘制图形,并旋转
- JAAS配置介绍(转载)
- “自动”与“自动(延迟启动)”
- hive 字符串拼接函数
- 人工智能正在向经济学领域渗透
- Ubuntu 1404
- markdown常用表情
- 井下测量类毕业论文文献都有哪些?