-
Notifications
You must be signed in to change notification settings - Fork 2
/
schedule.cpp
32 lines (29 loc) · 1.17 KB
/
schedule.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// schedule.cpp
// HackRiceX2020
//
// Created by Emily Chen on 2020/9/19.
// Copyright © 2020年 HackRiceX2020. All rights reserved.
//
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include "schedule.h"
void schedule(std::vector<Worker*>& workers, std::vector<Appointment>& appointments) {
std::sort(appointments.begin(), appointments.end(), [](auto& a, auto& b) { return a.getTimeEnd() < b.getTimeEnd(); });
for (auto& appointment : appointments) {
for (auto& worker : workers) {
// std::cout << worker->getName() << "\t | " << worker->getWorkingMinutes() << "\t | " << worker->getAvailableTime() << "\t | " << appointment.getTimeOfDayEnd() << std::endl;
if (worker->isCorrectAppointment(appointment.getType()) && worker->getAvailableTime() <= appointment.getTimeOfDayStart()) {
worker->addAppointment(appointment);
break;
}
}
std::sort(workers.begin(), workers.end(), [](auto& a, auto& b) { return *a < *b; });
// for (auto& worker: workers) {
// std::cout << worker->getName();
// }
// std::cout << std::endl;
}
}