Submission #167434

#TimeUsernameProblemLanguageResultExecution timeMemory
167434faremyTeams (IOI15_teams)C++14
0 / 100
4008 ms15232 KiB
#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; 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++) { 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...