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. Response.Redirect 打开新窗口的两种方法

    一般情况下,Response.Redirect 方法是在服务器端进行转向,因此,除非使用 Response.Write("<script>window.location='htt ...

  2. lambda匿名函数,sorted排序,filter()筛选,map()映射

    一丶匿名函数 语法: 函数名 = lambda参数:返回值 # 普通的正常的函数 def func(n): return n * n ret = func(9) print(ret) # 匿名函数 a ...

  3. 数学建模大赛-NO.1

    数学建模大赛-NO.1   论文精析 近期,在网上各种的收罗,张开了各式各样的捕抓.哈哈… .终于,在一个不经意之间发现了一个巨大无比的宝藏式的网站,此网站网址为:http://cjsxjm.gzsi ...

  4. 入口类和@SpringBootApplication

    SpringBoot通常有一个名为*Application的入口类,入口类里有一个标准的Java应用的入口方法,main方法,在该方法中使用SpringApplication.run(xxxxxApp ...

  5. ASP.NET Dev ASPxGridView控件使用 ASP.NET水晶报表打印

    1.ASPxGridView控件使用 2.ASP.NET水晶报表客户端打印 3.javascript打印 4.ASPxGridView根据Textbox查询 5. ASPxGridView 列宽 1. ...

  6. Redis常用特性

    发布订阅 ·服务器状态在pubsub_channels字典保存了所有频道的订阅关系:SUBSCRIBE命令负责将客户端和被订阅的频道关联到这个字典里面,而UNSUBSCRIBE命令则负责解除客户端和被 ...

  7. Aizu 0033 Ball(dfs,贪心)

    日文题面...题意:是把一连串的有编号的球往左或者往右边放.问能不能两边都升序. 记录左边和右边最上面的球编号大小,没有就-1,dfs往能放的上面放. #include<bits/stdc++. ...

  8. Android(java)学习笔记80:Html嵌入到Java显示乱码

    1. Html嵌入到Java显示乱码: 解决方案: 使用 loadData方法是中文部分会出现乱码,即使指定“utf-8”.“gbk”.“gb2312”也一样. webView.getSettings ...

  9. Android(java)学习笔记76:Handler用法总结 和 秒表案例

    一.Handler的定义: Handler主要接收子线程发送的数据, 并用此数据配合主线程更新UI,用来跟UI主线程交互用.比如可以用handler发送一个message,然后在handler的线程中 ...

  10. Flutter Json序列号和反序列化遇到问题 Missing "part 'xxx.g.dart';"

    /** * * 1.@JsonSerializable() 这是表示告诉编译器这个类是需要生成Model类的 * 2,@JsonKey 由于服务器返回的部分数据名称在Dart语言中是不被允许的, * ...