Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <deque>
- #include <iostream>
- #include <queue>
- #include <vector>
- struct proc {
- proc(int wf, int i)
- : when_free(wf)
- , id_(i)
- {
- }
- void update_time(int tm)
- {
- when_free = tm;
- }
- int time() const { return when_free; }
- int id() const { return id_; }
- friend bool cmp(const proc& lhs, const proc& rhs);
- private:
- int when_free;
- int id_;
- };
- bool cmp(const proc& lhs, const proc& rhs)
- {
- if (lhs.when_free == rhs.when_free)
- return lhs.id() < rhs.id();
- return lhs.when_free < rhs.when_free;
- }
- int main()
- {
- std::priority_queue<proc, std::vector<proc>, decltype(cmp)> pq(cmp);
- pq.push(proc(0, 0));
- pq.push(proc(1, 0));
- /*int n; // proc
- int m; // tasks
- std::cin >> n >> m;
- std::vector<int> tasks(m);
- for (auto & e : tasks) std::cin >> e;
- */
- std::cout << pq.top().time();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment