diff --git a/fnhid/PriorityQueue/1374.cpp b/fnhid/PriorityQueue/1374.cpp new file mode 100644 index 0000000..aff242f --- /dev/null +++ b/fnhid/PriorityQueue/1374.cpp @@ -0,0 +1,48 @@ +#include +#include +#include +#include + +struct Lecture +{ + long long start, end; +}; + +int max(int a, int b) +{ + return a > b ? a : b; +} + +using namespace std; + +int main() +{ + int n, id, answer=0; + priority_queue, greater> pq; + + + cin >> n; + vector v(n); + for (int i=0;i> id >> v[id-1].start >> v[id-1].end; + } + + sort(v.begin(), v.end(), [](const Lecture& a, const Lecture& b) + { + return a.start < b.start; + }); + + for (Lecture& l : v) + { + + while (!pq.empty() && pq.top() <= l.start) + pq.pop(); + pq.push(l.end); + answer = max(answer, (int)pq.size()); + } + + + cout << answer; + +} \ No newline at end of file