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 ...
随机推荐
- PHP session变量的销毁
1.何为session? 相当于一个客户端(可以是浏览器.app.ftp等其他,而且同一个浏览器多开几个又算是不同的客户端)对服务器的一个访问,这个期间服务器为此建立一个唯一的标示(session_i ...
- 来自于51CTO的经典学习资料汇总
移动开发类: 1.2012Android开发热门资料(110个) http://bbs.51cto.com/thread-934023-1.html 2.[绝对给力]Android开发免豆 ...
- SpringBoot | 第二十五章:日志管理之自定义Appender
前言 前面两章节我们介绍了一些日志框架的常见配置及使用实践.一般上,在开发过程中,像log4j2.logback日志框架都提供了很多Appender,基本上可以满足大部分的业务需求了.但在一些特殊需求 ...
- 【Python】python2 str 编码检测
python2 str 编码检测 import chardet s = 'sdffdfd' print type(s) print chardet.detect(s) s2 = '反反复复' prin ...
- css动画-模拟正余弦曲线
今天就写一个css3抛物线的动画吧= = 从左到右的抛物线动画,我们就暂且把动作分为匀速向右运动和变速的上下运动. 水平匀速运动我们可以利用 translateX(x):定义 2D 转换,沿着 X 轴 ...
- mongodb 认证方式(version:3.0.4)
之前一直在本机上跑,前段时间把后台架到云服务器上了,在settings里加上了username和password,希望同步的时候修改一下settings就能在本地测试. 因为云服务器端数据库连接需 ...
- 命令行启动mysql服务
在<计算机网络>课程中曾学过net命令,可以用于启动后台服务.在mysql中,net命令用于启动后台服务器进程mysqld,即后台服务. 不过,如果在普通用户模式下net start my ...
- 谷歌chrome://chrome-urls/
查看DNS解析时间 1 chrome://dns/ 查看DNS解析的地址 1 chrome://net-internals/#dns 更多功能请参考 1 chrome://chrome-urls/ 以 ...
- myeclipse引入工程后运行出错
An internal error occurred during: Launching efax on Tomcat 7.x . 项目运行时报错 因为你项目建的时候用的是Tomcat5.x 服务器 ...
- Android(java)学习笔记101:Java程序入口和Android的APK入口
1. Java程序的入口:static main()方法 public class welcome extends Activity { @Override public void onCreate( ...