이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "teams.h"
#include <algorithm>
#include <numeric>
#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;
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[])
{
if (std::accumulate(K, K + M, 0) > students)
return 0;
while (!canAssign.empty())
canAssign.pop();
std::sort(K, K + M);
int iStud = 0;
for (int iGroup = 0; iGroup < M; iGroup++)
{
while (!canAssign.empty() && canAssign.top().end < K[iGroup])
canAssign.pop();
for (; iStud < students && prefer[iStud].start <= K[iGroup]; iStud++)
canAssign.emplace(prefer[iStud]);
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... |