This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "teams.h"
#include "bits/stdc++.h"
using namespace std;
vector<pair<int,int>> intervals;
void init(int N, int A[], int B[])
{
intervals.resize(N);
for (int i = 0; i < N; ++i)
intervals[i] = {A[i], B[i]};
sort(intervals.begin(), intervals.end());
}
int can(int M, int K[])
{
sort(K, K + M);
priority_queue<int, vector<int>, greater<int>> pq; // b : end of interval
int idx = 0;
for (int i = 0; i < M; ++i)
{
int todo = K[i];
while (idx < (int)intervals.size() && intervals[idx].first <= K[i])
pq.push(intervals[idx++].second);
while (todo)
{
if (pq.empty())
return 0;
if (pq.top() >= K[i])
--todo;
pq.pop();
}
}
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |