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>
#define fi first
#define se second
using namespace std;
const int MX_N = 500042;
int n;
pair<int, int> stud[MX_N];
void init(int N, int A[], int B[]) {
for (int i = 0; i < N; i++)
stud[i] = {A[i], B[i]};
n = N;
sort(stud, stud + N);
}
int can(int M, int K[]) {
sort(K, K + M);
int nxt = 0;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> ranges {};
for (int i = 0; i < M; i++) {
while (nxt < n && stud[nxt].fi <= K[i]) {
ranges.push({stud[nxt].se, stud[nxt].fi});
nxt++;
}
int req = K[i];
while (!ranges.empty() && req) {
auto cur = ranges.top();
ranges.pop();
if (cur.fi >= K[i])
req--;
}
if (req != 0)
return 0;
}
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... |