poj3616
来源:互联网 发布:如何加强网络信息安全 编辑:程序博客网 时间:2024/05/20 01:34
https://vjudge.net/problem/16276/origin
题意: 给一些区间,然后去区间权和的最大值,注意每个区间取完之后需要休息:
#include<iostream>#include<cstdio>#include<algorithm>using namespace std;const int maxn = 1000 + 10;#define INF 0x3f3f3f3f#define eps 10e-8//const int maxn = 1000 + 10;int n,m,k;struct Node{int x;int y;int val;}a[maxn];bool cmp(Node x,Node y){if(x.x == y.x)return x.y < y.y;return x.x < y.x;}int main(){while( ~ scanf("%d%d%d",&n,&m,&k)){for(int i = 1; i <= m; i++){scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].val);}sort(a + 1,a + m + 1,cmp);int dp[maxn] = {0};for(int i = 1; i <= m; i++){for(int j = m; j >= i + 1; j --){if(a[j].x >= a[i].y + k){dp[j] = max(dp[j],dp[i] + a[i].val); }}}int ans = 0;for(int i = 1; i <= m; i ++){dp[i] += a[i].val;if(dp[i] > ans)ans = dp[i];}cout << ans << endl;}return 0;}
0 0
- poj3616
- poj3616
- POJ3616
- poj3616
- poj3616
- poj3616
- poj3616 dp
- poj3616 dp
- poj3616(LIS)
- POJ3616 MILKING TIME
- poj3616 Milking Time
- POJ3616 Milking Time 【DP】
- POJ3616 简单DP
- POJ3616---Milking Time
- poj3616 解题报告
- POJ3616:Milking Time
- poj3616 动态规划
- poj3616 Milking time
- 显示接口的实现
- 使用 Shipyard 部署 Docker 图形化
- 在Android中通过jni方式使用编译好的FFmpeg库-Android中使用FFmpeg媒体库(二)
- android:screenOrientation属性
- js数组循环
- poj3616
- pycharm激活码(注册码)
- 响应者链条
- 1002. A+B for Polynomials (25)
- 读《统计自然语言处理》——文本分析
- Qt软件开发文档6---dockWidget自定义标题栏
- Oracle中快速导入导出数据库的几种方式
- C语言复习笔记 1
- maven ClassNotFoundException: ContextLoaderListener