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的更多相关文章

  1. LeetCode 826. Most Profit Assigning Work

    原题链接在这里:https://leetcode.com/problems/most-profit-assigning-work/ 题目: We have jobs: difficulty[i] is ...

  2. 【LeetCode】826. Most Profit Assigning Work 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/most-pro ...

  3. [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 ...

  4. [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 ...

  5. 算法与数据结构基础 - 双指针(Two Pointers)

    双指针基础 双指针(Two Pointers)是面对数组.链表结构的一种处理技巧.这里“指针”是泛指,不但包括通常意义上的指针,还包括索引.迭代器等可用于遍历的游标. 同方向指针 设定两个指针.从头往 ...

  6. All LeetCode Questions List 题目汇总

    All LeetCode Questions List(Part of Answers, still updating) 题目汇总及部分答案(持续更新中) Leetcode problems clas ...

  7. Swift LeetCode 目录 | Catalog

    请点击页面左上角 -> Fork me on Github 或直接访问本项目Github地址:LeetCode Solution by Swift    说明:题目中含有$符号则为付费题目. 如 ...

  8. 【LeetCode】双指针 two_pointers(共47题)

    [3]Longest Substring Without Repeating Characters [11]Container With Most Water [15]3Sum (2019年2月26日 ...

  9. 【Leetcode周赛】从contest-81开始。(一般是10个contest写一篇文章)

    Contest 81 (2018年11月8日,周四,凌晨) 链接:https://leetcode.com/contest/weekly-contest-81 比赛情况记录:结果:3/4, ranki ...

随机推荐

  1. java多线程,如何防止脏读数据

    多线程容易“非线程安全”的情况,是由于用了全局变量,而又没有很好的控制起情况.所以无论做什么程序,谨慎使用全局变量 "非线程安全"其实会在多个线程对同一个对象中的实例变量进行并发访 ...

  2. PHP中文手册2

    11.异常处理 用户可以用自定义的异常处理类来扩展 PHP 内置的异常处理类.以下的代码说明了在内置的异常处理类中,哪些属性和方法在子类中是可访问和可继承的.译者注:以下这段代码只为说明内置异常处理类 ...

  3. Maven的学习资料收集--(九) 构建SSH项目以及专栏maven

    在这里整合一下,使用Maven构建一个SSH项目 1.新建一个Web项目 可以参照前面的博客 2.添加依赖,修改pom.xml <project xmlns="http://maven ...

  4. $.ajax仿axios封装

    适用于对老项目维护时,用习惯的axios不能使用的情况 基础封装: 保留 then 的回调.baseHref.method 传 post || get || etc, function ajax(ob ...

  5. [Freemarker] Getting Start

    Freemarker是一个模板引擎,在.NET中有类似的T4模板,FreeMarker对ASP.NET MVC也很友好,链接地址,引用官方的一幅图 模板+数据=视图 Following are the ...

  6. js之BOM和DOM

      今天我们来学习js中的一些基础的操作. 一.BOM对象 BOM(浏览器对象模型),可以对浏览器窗口进行访问和操作.使用 BOM,开发者可以移动窗口.改变状态栏中的文本以及执行其他与页面内容不直接相 ...

  7. form表单上传域(type="file")的使用----上传文件

    一,单个文件的上传 1.html/jsp页面 <%@ page language="java" contentType="text/html; charset=UT ...

  8. Angular CLI的简单使用(2)

    刚才创建了myApp这个项目,看一下这个项目的文件结构.    项目文件概览 Angular CLI项目是做快速试验和开发企业解决方案的基础. 你首先要看的文件是README.md. 它提供了一些如何 ...

  9. [Git] Create a new repository on the command line

    echo "# xxx" >> README.md git init git add README.md git commit -m "first commi ...

  10. ZooKeeper保证之单一视图(Single System Image)

    由于ZooKeeper的数据模型简单且全部在内存中,ZooKeeper的速度非常快.它提供了一系列保证(Guarantees): • 顺序一致性(Sequential Consistency) • 原 ...