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 <bits/stdc++.h>
#include "teams.h"
#define P pair<int,int>
#define pb push_back
#define mp make_pair
using namespace std;
int n;
multiset<P>intervals;
void init(int N, int A[], int B[]) {
n = N;
for(int i=0;i<N;i++) {
intervals.insert(mp(B[i], A[i]));
}
}
int OK[500100];
int can(int M, int K[]) {
sort(K, K+M);
int sum = 0;
for(int i=0;i<M;i++) {
OK[i] = K[i];
sum += K[i];
}
if(sum > n) return 0;
int taken = 0;
multiset<P>st = intervals;
for(int i=0;i<M;i++) {
for(int j=0;j<K[i];j++) {
auto x = st.lower_bound({OK[i], 0});
if(x == st.end()) return 0;
else if(K[i] >= (*x).second && K[i] <= (*x).first) {
taken++;
st.erase(st.lower_bound({OK[i], 0}));
}
}
}
return (taken == sum);
}
# | 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... |