当前位置:网站首页>Huawei interview question: Recruitment
Huawei interview question: Recruitment
2022-07-01 12:26:00 【Cool of Si Ku Quan Shu】
subject
A company organizes an open recruitment campaign , It is assumed that due to the limitation of number of people and site , The length of each interview varies , And has arranged for a given , use (S1, E1)、 (S2, E2)、 (Sj,Ej)…(Si < Ei , All non negative integers ) Indicate the start and end time of each interview . The interview is one-on-one , That is, an interviewer can only interview one candidate at the same time , After an interviewer completes an interview, he can immediately proceed to the next interview , And the number of interviewees of each interviewer shall not exceed m .
In order to support the efficient and smooth progress of recruitment activities , Please calculate how many interviewers you need at least .
Input description
The first line you enter is the maximum number of interviewers m , The second is the total number of interviews on that day n , Next n Behavior
Start time and end time of each interview , Start and end times are separated by spaces . among , 1 <= n, m <= 500
Output description
Output an integer , Indicates the minimum number of interviewers needed .
Example 1
Input
2
5
1 2
2 3
3 4
4 5
5 6
Output
3
explain :
All in all 5 Interview , And the interview time does not overlap , But each interviewer can only interview at most 2 Person time , So we need to 3 An interviewer .
Example 2
Input
3
3
1 2
2 3
3 4
Output
1
explain :
All in all 3 Interview , Interview times don't overlap , Each interviewer can interview at most 3 Person time , So you just need to 1 An interviewer .
Example 3
Input
3
3
8 35
5 10
1 3
Output
2
explain :
All in all 3 Interview 【5,10】 and 【8,35】 There is overlap , So at least 2 An interviewer .
analysis
First, sort , Then use a big top pile , Maintain the current end time of each interview ,
Then when a new schedule appears , Just decide whether you need a new interviewer , Or continue to use the previous conference room .
Code
#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;
}
边栏推荐
- [JS advanced] promise explanation
- [datawhale202206] pytorch recommendation system: precision model deepfm & DIN
- JS related interview questions and answers (1)
- Message queue monitoring refund task batch process
- AI matting tool
- Eurake分区理解
- Self organization is the two-way rush of managers and members
- 6.30模拟赛总结
- 二叉树的链式存储
- MySQL common functions
猜你喜欢
IOS interview
91.(cesium篇)cesium火箭发射模拟
Uniapp uses uni upgrade Center
【datawhale202206】pyTorch推荐系统:召回模型 DSSM&YoutubeDNN
C serialization simple experiment
[JS] interview questions
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
Sort out relevant contents of ansible
Powerful, easy-to-use, professional editor / notebook software suitable for programmers / software developers, comprehensive evaluation and comprehensive recommendation
[some notes]
随机推荐
Operations related to sequence table
Machine learning - Data Science Library - day two
指定的服务已标记为删除
《MATLAB 神经网络43个案例分析》:第40章 动态神经网络时间序列预测研究——基于MATLAB的NARX实现
Unity xlua co process packaging
LeetCode力扣(剑指offer 31-35)31. 栈的压入弹出序列32I.II.III.从上到下打印二叉树33. 二叉搜索树的后序遍历序列34. 二叉树中和为某一值的路径35. 复杂链表的复制
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 6
Arm GIC (V) how arm TrustZone supports security interrupt analysis notes.
Eurake分区理解
MySQL的零拷贝技术
Sleep quality today 79 points
One year anniversary of bitbear live studio, hero rally order! I invite you to take a group photo!
谈思生物直播—GENOVIS张洪妍抗体特异性酶切技术助力抗体药物结构表征
Ansible的playbook
微信小程序 – 80个实用的微信小程序项目实例
[datawhale202206] pytorch recommendation system: multi task learning esmm & MMOE
Dlhsoft Kanban, Kanban component of WPF
[datawhale202206] pytorch recommendation system: recall model DSSM & youtubednn
(mixed version 1) multiple TXT text to one table
硬阈值(Hard Thresholding)函数解读[通俗易懂]