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 <algorithm>
#include <queue>
struct Interval
{
int start, end;
bool operator <(const Interval &other) const
{
return (other.end < end);
}
};
const int MAXN = 1e5;
int students;
Interval prefer[MAXN];
std::priority_queue<Interval> canAssign;
long long groupSizes[MAXN];
void init(int N, int A[], int B[])
{
students = N;
for (int iStud = 0; iStud < students; iStud++)
{
prefer[iStud].start = A[iStud];
prefer[iStud].end = B[iStud];
}
std::sort(prefer, prefer + students, [](const Interval &a, const Interval &b) { return (a.start != b.start ? a.start < b.start : a.end < b.end); });
}
int can(int M, int K[])
{
long long sizeSum = 0;
for (int iGroup = 0; iGroup < M; iGroup++)
{
sizeSum += K[iGroup];
if (sizeSum > students)
return 0;
}
while (!canAssign.empty())
canAssign.pop();
std::sort(K, K + M);
int iStud = 0;
for (int iGroup = 0; iGroup < M; iGroup++)
{
for (; iStud < students && prefer[iStud].start <= K[iGroup]; iStud++)
canAssign.emplace(prefer[iStud]);
while (!canAssign.empty() && canAssign.top().end < K[iGroup])
canAssign.pop();
if ((int)canAssign.size() < K[iGroup])
return 0;
for (int iAssign = 0; iAssign < K[iGroup]; iAssign++)
canAssign.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... |