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>
using namespace std;
int n, a[500100], b[500100];
void init(int N, int A[], int B[]) {
n = N;
for(int i = 0; i < n; i++)
a[i] = A[i], b[i] = B[i];
}
int can(int M, int K[]) {
int S = 0;
for(int i = 0; i < M; i++) S += K[i];
if(S > n) return 0;
multiset<pair<int, int> > st;
for(int i = 0; i < n; i++) {
st.insert({b[i], a[i]});
}
sort(K, K + M);
for(int i = 0; i < M; i++) {
int h = K[i];
for(auto it = st.begin(); it != st.end() && h; ) {
if(it -> second <= K[i] && K[i] <= it -> first) {
auto x = it; it++;
st.erase(x); h--;
} else it++;
}
if(h) 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... |