You are viewing a single comment's thread. Return to all comments →
Earliest Finish Time Greedy Algorithm
int CalculateMaxWorkshops(Available_Workshops* ptr) { sort(ptr->workshops, ptr->workshops + ptr->n, [](const auto& a, const auto& b) { return a.end_time < b.end_time; }); map<int, int> m; for (int i = 0; i < ptr->n; i++) { auto iter = m.upper_bound(ptr->workshops[i].start_time); if (iter == m.end()) m[ptr->workshops[i].end_time] = i; } return m.size();
Seems like cookies are disabled on this browser, please enable them to open this website
Attending Workshops
You are viewing a single comment's thread. Return to all comments →
Earliest Finish Time Greedy Algorithm