当前位置:网站首页>华为面试题: 招聘
华为面试题: 招聘
2022-07-01 12:25:00 【四库全书的酷】
题目
某公司组织一场公开招聘活动,假设由于人数和场地的限制,每人每次面试的时长不等,并已经安排给定,用 (S1, E1)、 (S2, E2)、 (Sj,Ej)…(Si < Ei ,均为非负整数 )表示每场面试的开始和结束时间。面试采用一对一的方式,即一名面试官同时只能面试一名应试者,一名面试官完成一次面试后可以立即进行下一场面试,且每个面试官的面试人次不超过 m 。
为了支撑招聘活动高效顺利进行,请你计算至少需要多少名面试官。
输入描述
输入的第一行为面试官的最多面试人次 m ,第二行为当天总的面试场次 n ,接下来的 n 行为
每场面试的起始时间和结束时间,起始时间和结束时间用空格分隔。 其中, 1 <= n, m <= 500
输出描述
输出一个整数,表示至少需要的面试官数量。
示例1
输入
2
5
1 2
2 3
3 4
4 5
5 6
输出
3
说明 :
总共有5 场面试,且面试时间都不重叠,但每个面试官最多只能面试 2 人次,所以需要 3 名面试官。
示例2
输入
3
3
1 2
2 3
3 4
输出
1
说明:
总共有3 场面试,面试时间都不重叠,每个面试官最多能面试 3 人次,所以只需要 1 名面试官。
示例3
输入
3
3
8 35
5 10
1 3
输出
2
说明:
总共有3 场面试【5,10】和 【8,35】 有重叠,所以至少需要 2 名面试官。
分析
首先进行一下排序,然后用一个大顶堆,维护当前每次面试的结束时间,
然后当一个新的时间安排出现的时候,只需要判断一下是否需要新的一个面试官,还是继续使用之前的会议室。
代码
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int m,n;
cin >> m >> n;
vector<pair<int,int>> cap;
for(int i = 0; i < n; ++i){
int tmp1,tmp2;
cin >> tmp1 >> tmp2;
cap.push_back({
tmp1,tmp2});
}
sort(cap.begin(),cap.end(),[](pair<int,int>&a, pair<int,int>&b){
return a.first < b.first;
});
vector<priority_queue<int>> cap2(1);
for(int i = 0; i < cap.size(); ++i){
auto x = cap[i];
priority_queue<int> tmp;
int flag = 1;
for(int i = 0; i < cap2.size(); ++i){
if(cap2[i].empty() || cap2[i].top() <= x.first){
cap2[i].push(x.second);
flag = 0;
break;
}
}
if(flag){
tmp.push(x.second);
cap2.push_back(tmp);
}
}
int ans = 0;
for(int i = 0;i < cap2.size(); ++i){
int tmp = cap2[i].size();
ans += tmp % m ? (tmp / m + 1) : ( tmp / m );
}
cout << ans << endl;
return 0;
}
边栏推荐
- 迅为i.MX8Mmini开发板离线构建Yocto系统
- Le semester manquant
- Machine learning - Data Science Library - day two
- Leetcode force buckle (Sword finger offer 31-35) 31 Stack push pop-up sequence 32i II. 3. Print binary tree from top to bottom 33 Post order traversal sequence 34 of binary search tree The path with a
- Understanding of NAND flash deblocking
- Arm GIC (V) how arm TrustZone supports security interrupt analysis notes.
- 双链表有关操作
- [JS advanced] promise explanation
- 【datawhale202206】pyTorch推荐系统:精排模型 DeepFM&DIN
- [Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 7
猜你喜欢

Computer graduation project asp Net hotel room management system VS development SQLSERVER database web structure c programming computer web page source code project
![[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 4](/img/4f/bc6c39ef4f2d1c4bdad8420f7badac.jpg)
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 4

迅为i.MX8Mmini开发板离线构建Yocto系统

Uniapp uses uni upgrade Center

Onenet Internet of things platform - mqtt product equipment upload data points
![[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 6](/img/0e/0900e386f3baeaa506cc2c1696e22a.jpg)
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 6

Typora realizes automatic uploading of picture pasting

C serialization simple experiment
![[Yunju entrepreneurial foundation notes] Chapter VII Entrepreneurial Resource test 1](/img/be/1194125442aaa2d7cc20b6a4a6762a.jpg)
[Yunju entrepreneurial foundation notes] Chapter VII Entrepreneurial Resource test 1

Switch basic experiment
随机推荐
自组织是管理者和成员的双向奔赴
AI matting tool
Rural guys earn from more than 2000 a month to hundreds of thousands a year. Most brick movers can walk my way ǃ
[Suanli network] technological innovation of Suanli Network -- key technology of operation service
强大、好用、适合程序员/软件开发者的专业编辑器/笔记软件综合评测和全面推荐
The operation process of using sugar to make a large data visualization screen
How to use opcache, an optimization acceleration component of PHP
IOS interview
91.(cesium篇)cesium火箭發射模擬
ASP.NET Core 6 从入门到企业级实战开发应用技术汇总
ASTM D 3801固体塑料垂直燃烧试验
双链表有关操作
Golang introduces the implementation method of the corresponding configuration file according to the parameters
2022-06-28-06-29
Use of easyexcel
Ipv6-6to4 experiment
Leetcode force buckle (Sword finger offer 31-35) 31 Stack push pop-up sequence 32i II. 3. Print binary tree from top to bottom 33 Post order traversal sequence 34 of binary search tree The path with a
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 2
Eurake分区理解
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 3