当前位置:网站首页>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;
}
边栏推荐
- Good luck brought by years of persistence
- Understanding of NAND flash deblocking
- [Maui] add click events for label, image and other controls
- ASTM D 3801 vertical burning test of solid plastics
- Wechat applet reports an error: [rendering layer network layer error] pages/main/main Local resource pictures in wxss cannot be obtained through wxss. You can use network pictures, Base64, or < image/
- 第十四章 信号(四)- 多进程任务示例
- [datawhale202206] pytorch recommendation system: precision model deepfm & DIN
- 手把手教你完成图像分类实战——基于卷积神经网络的图像识别
- 微信模拟地理位置_伪装微信地理位置
- What are the PHP FPM configuration parameters
猜你喜欢

Sort out relevant contents of ansible
![[20220605] Literature Translation -- visualization in virtual reality: a systematic review](/img/11/6c42957186bf530e8f9d4025a40197.png)
[20220605] Literature Translation -- visualization in virtual reality: a systematic review

队列的链式存储

【语音信号处理】3语音信号可视化——prosody

双链表有关操作

Virtualenv+pipenv virtual environment management

One year anniversary of bitbear live studio, hero rally order! I invite you to take a group photo!

I wish you all a happy reunion

The Missing Semester

Message queue monitoring refund task batch process
随机推荐
leetcode 406. Queue Reconstruction by Height(按身高重建队列)
Onenet Internet of things platform - create mqtts products and devices
[Yunju entrepreneurial foundation notes] Chapter VII Entrepreneurial Resource test 1
Implementation of address book management system with C language
CPI教程-异步接口创建及使用
Typora realizes automatic uploading of picture pasting
usb peripheral 驱动 - cable connect/disconnect
【语音信号处理】3语音信号可视化——prosody
【MAUI】为 Label、Image 等控件添加点击事件
LeetCode 454. Add four numbers II
Unity XLua 协程封装
[some notes]
2022-06-28-06-29
AI matting tool
[20211129] jupyter notebook remote server configuration
Ansi/ul 94 VTM vertical burning test for thin materials
GID:旷视提出全方位的检测模型知识蒸馏 | CVPR 2021
栈-------
Ipv6-6to4 experiment
GID: open vision proposes a comprehensive detection model knowledge distillation | CVPR 2021