背包问题,把任务按截止日期排序,再按背包问题处理~

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+;
struct node {
int c;
int w;
int ddl;
}Node[maxn];
int dp[maxn];
bool cmp (node a,node b) {
return a.ddl<b.ddl;
}
int main () {
int N;
int maxddl=;
scanf ("%d",&N);
for (int i=;i<=N;i++) {
scanf ("%d %d %d",&Node[i].w,&Node[i].c,&Node[i].ddl);
maxddl=max(maxddl,Node[i].ddl);
}
sort (Node+,Node+N+,cmp);
for (int i=;i<=N;i++) {
for (int j=maxddl;j>=Node[i].c;j--)
if (j<=Node[i].ddl) dp[j]=max(dp[j],dp[j-Node[i].c]+Node[i].w);
}
int Max=;
for (int i=;i<=maxddl;i++) Max=max(Max,dp[i]);
printf ("%d",Max);
return ;
}

PAT T1002 Business的更多相关文章

  1. PAT-Top1002. Business (35)

    在一个项目的截止日期之前,如果工期有空闲则可能可以开展其他项目,提高效益.本题考查动态规划.数组dp[i][t]表示在截止时间为t时,前i个项目工作安排能够产生的最大收益,而前i个项目的截止时间都不大 ...

  2. PAT顶级 1002. Business (35)

    PAT顶级 1002. Business (35) As the manager of your company, you have to carefully consider, for each p ...

  3. PAT (Top Level)1002. Business DP/背包

    As the manager of your company, you have to carefully consider, for each project, the time taken to ...

  4. 在 SharePoint Server 2016 本地环境中设置 OneDrive for Business

    建议补丁 建议在sharepoint2016打上KB3127940补丁,补丁下载地址 https://support.microsoft.com/zh-cn/kb/3127940 当然不打,也可以用O ...

  5. 《转载》PAT 习题

    博客出处:http://blog.csdn.net/zhoufenqin/article/details/50497791 题目出处:https://www.patest.cn/contests/pa ...

  6. Java Business Process Management(业务流程管理) 初识环境搭建

    一.简介 (一)什么是jbpm JBPM,全称是Java Business Process Management(业务流程管理),它是覆盖了业务流程管理.工作流.服务协作等领域的一个开源的.灵活的.易 ...

  7. PAT Judge

    原题连接:https://pta.patest.cn/pta/test/16/exam/4/question/677 题目如下: The ranklist of PAT is generated fr ...

  8. PAT/字符串处理习题集(二)

    B1024. 科学计数法 (20) Description: 科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式[+-][1-9]"."[0-9]+E[+ ...

  9. Tips for Planning Your Business Startup

    原文链接:http://domaintree.me/?p=1037 By Robert Thibodeau –  Starting a business can be a very daunting ...

随机推荐

  1. 使用jenkins 实现 .net core项目自动发布到 docker

    在Docker内运行Jenkins pull镜像  docker pull jenkins/jenkins:lts Dockerfile FROM jenkins/jenkins:lts USER r ...

  2. Shiro&Jwt验证

    此篇基于 SpringBoot 整合 Shiro & Jwt 进行鉴权 相关代码编写与解析 首先我们创建 JwtFilter 类 继承自 BasicHttpAuthenticationFilt ...

  3. js加密(七)steam登录

    1. url: https://store.steampowered.com/login/?redir=&redir_ssl=1 2. target: 登录 3. 分析 3.1 老样子,抓包, ...

  4. 豆瓣工程师为你解答关于 Python3 编程方面的问题

    Python是如此活跃的一种语言,几乎伴随互联网的发生而创立,又伴随互联网的极速发展而繁荣.使用Python会遇到这样的问题:什么时候该用多进程?怎样提高代码执行效率?Flask为什么流行?学习Pyt ...

  5. 吴裕雄 python 神经网络——TensorFlow图片预处理

    import numpy as np import tensorflow as tf import matplotlib.pyplot as plt # 使用'r'会出错,无法解码,只能以2进制形式读 ...

  6. javascript 删除对象的属性 delete

    1.当属性存在 configurable:true delete命令会返回true var obj={a:1}; delete obj.a //true console.log(obj);//{} 2 ...

  7. 树状数组(fenwick tree)

    树状数组又称芬威克树,概念上是树状,实际上是使用数组实现的,表现为一种隐式数据结构,balabala...详情请见:https://en.wikipedia.org/wiki/Fenwick_tree ...

  8. utf-8无bom格式编码

    BOM——Byte Order Mark,就是字节序标记 在UCS 编码中有一个叫做"ZERO WIDTH NO-BREAK SPACE"的字符,它的编码是FEFF.而FFFE在U ...

  9. Centos7 虚拟环境安装Django 出现ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' %Database.sqlite_version)错误

    Centos7 虚拟环境安装Django 出现SQLite版本问题 raise ImproperlyConfigured('SQLite 3.8.3 or later is required (fou ...

  10. Flask - g变量

    传送门 http://flask.pocoo.org/docs/1.0/appcontext/#storing-data http://flask.pocoo.org/docs/1.0/appcont ...