方法:

class Solution:
def jobScheduling(self, startTime: List[int], endTime: List[int], profit: List[int]) -> int: idx=[i for i in range(len(startTime))] idx.sort(key=lambda i:endTime[i]) dp = [0 for i in range(len(startTime))]
dp[idx[0]]=profit[idx[0]]
for i in range(1,len(startTime)):
l=0
r=i-1 while(l<r):
mid = int((l+r+1)/2)
if(endTime[idx[mid]] > startTime[idx[i]]):
r=mid-1
else:
l=mid
if(endTime[idx[l]]<=startTime[idx[i]]):
dp[idx[i]]=max(dp[idx[l]]+profit[idx[i]],dp[idx[i-1]])
else:
dp[idx[i]]=max(profit[idx[i]],dp[idx[i-1]]) return max(dp)

leetcode-159周赛-5233-规划兼职工作*的更多相关文章

  1. 【js】Leetcode每日一题-完成所有工作的最短时间

    [js]Leetcode每日一题-完成所有工作的最短时间 [题目描述] 给你一个整数数组 jobs ,其中 jobs[i] 是完成第 i 项工作要花费的时间. 请你将这些工作分配给 k 位工人.所有工 ...

  2. [LeetCode] 159. Longest Substring with At Most Two Distinct Characters 最多有两个不同字符的最长子串

    Given a string s , find the length of the longest substring t  that contains at most 2 distinct char ...

  3. 【LeetCode】1466. 重新规划路线 Reorder Routes to Make All Paths Lead to the City Zero (Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 DFS BFS 日期 题目地址:https://lee ...

  4. leetcode 双周赛9 进击的骑士

    一个坐标可以从 -infinity 延伸到 +infinity 的 无限大的 棋盘上,你的 骑士 驻扎在坐标为 [0, 0] 的方格里. 骑士的走法和中国象棋中的马相似,走 “日” 字:即先向左(或右 ...

  5. LeetCode双周赛#36

    1604. 警告一小时内使用相同员工卡大于等于三次的人 题目链接 题意 给定两个字符串数组keyName和keyTime,分别表示名字为keytime[i]的人,在某一天内使用员工卡的时间(格式为24 ...

  6. ✡ leetcode 159. Longest Substring with At Most Two Distinct Characters 求两个字母组成的最大子串长度 --------- java

    Given a string, find the length of the longest substring T that contains at most 2 distinct characte ...

  7. 第三个Sprint完结工作 用场景来规划测试工作.

    一.根据用户使用场景测试: 1.流程 典型群体 群体 张小明 年龄 7-12岁 职业 小学生 收入 压岁钱还有零花钱 能力 看一些简单的数,做一些相对简单的事 爱好 玩游戏 典型场景 张小明平时喜欢玩 ...

  8. [LeetCode#159] Missing Ranges Strobogrammatic Number

    Problem: Given a string, find the length of the longest substring T that contains at most 2 distinct ...

  9. leetcode[159] Longest Substring with At Most Two Distinct Characters

    找到最多含有两个不同字符的子串的最长长度.例如:eoeabc,最长的是eoe为3,其他都为2. 思路: 用p1,p2表示两种字符串的最后一个出现的下标位置.初始p1为0. p2为-1.start初始化 ...

随机推荐

  1. 【转载】vue-cli搭建的环境,用nginx做代理服务器,访问时显示:Invalid Host header

    来源:https://blog.csdn.net/Cookysurongbin/article/details/86077241 vue-cli搭建的环境,用nginx做代理服务器,访问时显示:Inv ...

  2. 2018-10-19-C#-GUID-ToString-

    title author date CreateTime categories C# GUID ToString lindexi 2018-10-19 9:4:44 +0800 2018-4-1 10 ...

  3. [转]【Git】rebase 用法小结

    https://www.jianshu.com/p/4a8f4af4e803 本文主要参考 https://git-scm.com/docs/git-rebase rebase在git中是一个非常有魅 ...

  4. htop资源管理器

    htop是linux资源管理器,安装后界面如下图: 当我们用安装yum -y htop时,会报错,这是因为需要安装扩展源 yum -y epel 扩展源 安装完扩展源之后,就可以安装了

  5. js两个数组去重后,绑定控件,并支持模糊搜索数组项以及数组互移

    设计大概是这个样子的,很简单,两个div,两个互移按钮,一个搜索框,要求搜索框输入时,触发待选框的搜索项 <input class="form-control" placeh ...

  6. Codeforces 251C Number Transformation DP, 记忆化搜索,LCM,广搜

    题意及思路:https://blog.csdn.net/bossup/article/details/37076965 代码: #include <bits/stdc++.h> #defi ...

  7. MapFields和并行计算(OpenFOAM)

    这几天研究了一下OpenFOAM里的MapFields和并行计算,总结一下. Case 1 先进行并行计算 SetFields 初始化流场 decomposePar 把初始化好的流场分块 mpirun ...

  8. Delphi ResourceString的用法

    在Delphi编程的那段“古老”的日子里(就是在版本4之前),在程序中使用字符串有两个基本的方法.你可以使用字符串将它们嵌入到源程序中,例如: MessageDlg( 'Leave your stin ...

  9. 【NOI2019模拟2019.6.29】组合数(Lucas定理、数位dp)

    Description: p<=10且p是质数,n<=7,l,r<=1e18 题解: Lucas定理: \(C_{n}^m=C_{n~mod~p}^{m~mod~p}*C_{n/p} ...

  10. Vue 事件相关实例方法---on/emit/off/once

    一.初始位置 平常项目中写逻辑,避免不了注册/触发各种事件 今天来研究下 Vue 中,我们平常用到的关于 on/emit/off/once 的实现原理 关于事件的方法,是在 Vue 项目下面文件中的 ...