博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【POJ 1821】Fence
阅读量:4457 次
发布时间:2019-06-08

本文共 2037 字,大约阅读时间需要 6 分钟。

Fence
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 6933   Accepted: 2309

Description

A team of k (1 <= K <= 100) workers should paint a fence which contains N (1 <= N <= 16 000) planks numbered from 1 to N from left to right. Each worker i (1 <= i <= K) should sit in front of the plank Si and he may paint only a compact interval (this means that the planks from the interval should be consecutive). This interval should contain the Si plank. Also a worker should not paint more than Li planks and for each painted plank he should receive Pi $ (1 <= Pi <= 10 000). A plank should be painted by no more than one worker. All the numbers Si should be distinct. 
Being the team's leader you want to determine for each worker the interval that he should paint, knowing that the total income should be maximal. The total income represents the sum of the workers personal income. 
Write a program that determines the total maximal income obtained by the K workers. 

Input

The input contains: 
Input 
N K 
L1 P1 S1 
L2 P2 S2 
... 
LK PK SK 
Semnification 
N -the number of the planks; K ? the number of the workers 
Li -the maximal number of planks that can be painted by worker i 
Pi -the sum received by worker i for a painted plank 
Si -the plank in front of which sits the worker i 

Output

The output contains a single integer, the total maximal income.

Sample Input

8 43 2 23 2 33 3 51 1 7

Sample Output

17

Hint

Explanation of the sample: 
the worker 1 paints the interval [1, 2]; 
the worker 2 paints the interval [3, 4]; 
the worker 3 paints the interval [5, 7]; 
the worker 4 does not paint any plank 

Source

题解:先来见证一下没有单调队列优化的DP

          (我自己测了两组数据对拍都没有问题,一提交POJ就WA,哭了,明明应该TLE的。。。)

#include
#include
#include
#include
#include
#include
#include
using namespace std;const int N=20002;int k,n;struct node{ int l,p,s;}a[105];int dp[103][N],ans;bool cmp(node aa,node bb){ return aa.s

 

转载于:https://www.cnblogs.com/wuhu-JJJ/p/11337036.html

你可能感兴趣的文章
SignalR主动通知订阅者示例
查看>>
golang的表格驱动测试
查看>>
用python实现矩阵转置
查看>>
linux 小技巧(磁盘空间搜索)
查看>>
iOS开发——捕获崩溃信息
查看>>
(for 循环)编程找出四位整数 abcd 中满足 (ab+cd)(ab+cd)=abcd 的数
查看>>
tomcat使用spring-loaded实现应用热部署
查看>>
boost1.53中的lock-free
查看>>
链表_leetcode203
查看>>
基于ajax 的 几个例子 session ,ajax 实现登录,验证码 ,实现ajax表单展示
查看>>
连接不上sql server服务器的解决方案
查看>>
记录安装oracle的那些事(二)之双系统安装
查看>>
c3po数据库连接池中取出连接
查看>>
bootstrap-table 分页
查看>>
使用本机IP调试web项目
查看>>
【Java面试题】58 char型变量中能不能存贮一个中文汉字?为什么?
查看>>
C++ Primer 第六章 函数
查看>>
交互设计算法基础(3) - Quick Sort
查看>>
Ubuntu各种软件的安装
查看>>
智能社的邀请码
查看>>