POJ
来源:互联网 发布:linux下sleep 的用法 编辑:程序博客网 时间:2024/06/01 09:53
题目链接:http://poj.org/problem?id=3616
题意:给许多时间段和这些时间段的收益,并且一个时间段做完后要隔r时间才能进行下一个,问你收益最大为多大
思路:仔细一想就是一个把每个时间段任务看成一个点的LIS,只不过要先按时间排一下。
代码:
#include <cstdio>#include <cmath>#include <iostream>#include <cstring>#include <algorithm>#include <queue>#include <stack>#include <vector>#include <map>#include <numeric>#include <set>#include <string>#include <cctype>#include <sstream>#define INF 0x3f3f3f3fusing namespace std;typedef long long LL;typedef pair<LL, LL> P;const int maxn = 1e3 + 5;const int mod = 1e8 + 7;int n,m,r;int dp[maxn];struct node { int st,ed,v;}a[maxn];bool cmp(node x,node y){ return x.st<y.st;}int main() { while (~scanf ("%d%d%d",&n,&m,&r)){ for (int i=1;i<=m;i++){ scanf ("%d%d%d",&a[i].st,&a[i].ed,&a[i].v); a[i].ed+=r; } sort(a+1,a+m+1,cmp); for (int i=1;i<=m;i++) { dp[i]=a[i].v; } int Max=-INF; for (int i=2;i<=m;i++){ for (int j=1;j<i;j++){ if(a[j].ed<=a[i].st) { dp[i]=max(dp[i],dp[j]+a[i].v); } } Max=max(Max,dp[i]); } printf ("%d\n",Max); } return 0;}
阅读全文
0 0
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- 深度学习(十五)基于DCNN的人脸特征点定位-CVPR 2013
- Android Studio3.0开发JNI流程------Java调用C++以及C++调用Java
- Android发展趋势分析
- JSP基础(二十一)——JSTL核心标签
- 与adb相关的问题,比如掉线问题、Android Studio 提示Session 'app':Error Installing APK、找不到设备
- POJ
- 利用自定义消息(MFC界面)实现进程间通讯
- 多线程编程预习
- WdatePicker.js没有权限
- 论app维护对成功的重要性
- 已将该虚拟机配置为使用 64 位客户机操作系统。但是,无法执行 64 位操作。
- SQL----关系型数据库之数据查询
- linux网络协议栈内核分析
- git项目收藏