826. Most Profit Assigning Work
https://leetcode.com/problems/most-profit-assigning-work/description/
class Solution {
public:
int maxProfitAssignment(vector<int>& difficulty, vector<int>& profit, vector<int>& worker) {
int res = ;
vector<pair<int,int>> jobs(difficulty.size());
for (int i = ; i < difficulty.size(); i++)
jobs[i] = { difficulty[i], profit[i] };
sort(jobs.begin(), jobs.end());
sort(worker.begin(), worker.end());
int i = , j = , p = ;
while (j < worker.size()) {
while (i < jobs.size() && jobs[i].first <= worker[j]) {
p = max(p, jobs[i].second);
i++;
}
res += p;
j++;
}
return res;
}
};
826. Most Profit Assigning Work的更多相关文章
- LeetCode 826. Most Profit Assigning Work
原题链接在这里:https://leetcode.com/problems/most-profit-assigning-work/ 题目: We have jobs: difficulty[i] is ...
- 【LeetCode】826. Most Profit Assigning Work 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/most-pro ...
- [Swift]LeetCode826. 安排工作以达到最大收益 | Most Profit Assigning Work
We have jobs: difficulty[i] is the difficulty of the ith job, and profit[i] is the profit of the ith ...
- [LeetCode] Most Profit Assigning Work 安排最大利润的工作
We have jobs: difficulty[i] is the difficulty of the ith job, and profit[i] is the profit of the ith ...
- 算法与数据结构基础 - 双指针(Two Pointers)
双指针基础 双指针(Two Pointers)是面对数组.链表结构的一种处理技巧.这里“指针”是泛指,不但包括通常意义上的指针,还包括索引.迭代器等可用于遍历的游标. 同方向指针 设定两个指针.从头往 ...
- All LeetCode Questions List 题目汇总
All LeetCode Questions List(Part of Answers, still updating) 题目汇总及部分答案(持续更新中) Leetcode problems clas ...
- Swift LeetCode 目录 | Catalog
请点击页面左上角 -> Fork me on Github 或直接访问本项目Github地址:LeetCode Solution by Swift 说明:题目中含有$符号则为付费题目. 如 ...
- 【LeetCode】双指针 two_pointers(共47题)
[3]Longest Substring Without Repeating Characters [11]Container With Most Water [15]3Sum (2019年2月26日 ...
- 【Leetcode周赛】从contest-81开始。(一般是10个contest写一篇文章)
Contest 81 (2018年11月8日,周四,凌晨) 链接:https://leetcode.com/contest/weekly-contest-81 比赛情况记录:结果:3/4, ranki ...
随机推荐
- ZK配置文件
The number of milliseconds of each tick, 最小时间单位,很多运行时的时间 #间隔都是使用tickTime的倍数来表示的,例如initLimit=10就是tick ...
- 使用fastcgi_cache加速你的Nginx网站
很久以前在TW上挖了个坑,说nginx的fastcgi_cache是被大家忽视的一大金矿,今天把这个坑填上. 对于变化不太频繁的数据,大家都比较喜欢存Memcached以减少数据库的读取,但还是会有语 ...
- Lambda动态排序通用方法
using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; us ...
- 转---JS 获取鼠标左右键
原文:http://blog.csdn.net/mine3333/article/details/7291557 function test() { alert(event.x+" &quo ...
- <Android 基础(五)> MVVM
介绍 MVVM,Model-View-ViewModel,与上次讲的MVP模式比较的类似,MVP中需要大量的接口文件,而MVVM模式下,View和ViewModel直接关联,使用上比较方便,简化了代码 ...
- SqlServer报错:主体“dbo”不存在
某台SqlServer数据库执行订阅发布的时候,报错: 无法作为数据库主体执行,因为主体“dbo”不存在.无法模拟这种类型的主体,或您没有所需的权限.(源:MSSQLServer,错误号:15517) ...
- LeetCode Move Zeroes (简单题)
题意: 给定一个整型数组nums,要求将其中所有的0移动到末尾,并维护所有非0整数的相对位置不变. 思路: 扫一遍,两个指针维护0与非0的交界,将非0的数向前赋值就行了. C++ class Solu ...
- 如何在Java代码中使用SAP云平台CloudFoundry环境的环境变量
本文使用的例子源代码在我的github上. 在我的公众号文章在SAP云平台的CloudFoundry环境下消费ABAP On-Premise OData服务介绍了如何通过Cloud Connector ...
- 如何修改集群的公网信息(包括 VIP) (文档 ID 1674442.1)
适用于: Oracle Database - Enterprise Edition - 版本 11.2.0.3 到 12.1.0.2 [发行版 11.2 到 12.1]本文档所含信息适用于所有平台 用 ...
- pip 安装出现异常
MacBookPro:~ mac$ pip install numpy Collecting numpy Downloading numpy-1.13.1-cp35-cp35m-macosx_10_6 ...