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;
vector <pair <int, int>> v;
void init(int N, int A[], int B[]) {
n = N;
for(int i = 0;i < n;i++){
v.push_back({A[i], B[i]});
}
return;
}
int can(int M, int K[]) {
vector <int> k;
int m = M;
for(int i = 0;i < m;i++){
k.push_back(K[i]);
}
sort(k.begin(), k.end());
vector <pair <int, int>> conc;
for(int i = 0;i < n;i++){
if(v[i].second < k[0] or v[i].first > k[m-1]) continue;
int l = 0, r = m-1;
while(r-l > 1){
int mid = (l+r)/2;
if(k[mid] > v[i].second){
r = mid-1;
}
else l = mid;
}
if(k[r] <= v[i].second) l = r;
else r = l;
int a = l;
l = 0; r = m-1;
while(r - l > 1){
int mid = (l+r)/2;
if(k[mid] < v[i].first){
l = mid+1;
}
else r = mid;
}
if(v[i].first <= k[l]) r = l;
else l = r;
int b = l;
conc.push_back({k[a], k[b]});
// cout << a << ' ' << b << endl;
}
sort(conc.begin(), conc.end());
int l = n-1;
reverse(k.begin(), k.end());
for(auto x : k){
int cnt = x;
while(cnt > 0){
if(l < 0) return 0;
// cout << v[l].first << ' ' << v[l].second << ' ' << x << endl;
if(conc[l].first <= x and x <= conc[l].second){
cnt--;
}
l--;
}
}
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... |