HEU The message
来源:互联网 发布:用友erp软件价格 编辑:程序博客网 时间:2024/06/11 12:15
囧啊,读错题了,一直在想为什么是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
- HEU Mining Station on the Sea(最小费用最大流)
- The WM_NCHITTEST Message
- The first message
- the last message
- Decode the Encypted Message
- Decode the Encypted Message
- the message in program
- Passing the Message
- Passing the Message
- Passing the Message
- heu oj 1011 square
- HEU 3014 Piggy-Bank
- heu 1010 dfs (木棍)
- HEU Monkey CC
- HEU euler path
- HEU acm 1003
- heu acm基础训练 1001
- 浅谈扫频仪在LTE清频测试中的运用
- 艾级计算机的发展前景与挑战
- gcc -I -L -l区别
- (2013-4-21)数据结构实验三:狐狸逮兔问题(方法二:链式)
- 搭建 Android 开发环境,初试HelloWorld (win7) (上)
- HEU The message
- goldengate veridata 数据库表-通过监控软件实现邮件、短信报警
- poj 1160
- 小米2在Eclipse 调试,要注意下列步骤。
- VC++深入详解笔记---第6章_菜单---6.4 动态菜单操作
- opencv+VS2005安装说明
- linux kernel 启动性能优化
- POJ3204( Ikki's Story I - Road Reconstruction)
- 为什么static修饰的方法能不能调用非static方法和属性,请讲详细点