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;
#define pb push_back
typedef pair <int,int> ii;
int n;
int* a;
int* b;
void init(int N, int A[], int B[])
{
n=N;
a=A;
b=B;
}
int can(int M, int K[])
{
sort(K,K+M);
vector <ii> s;
for(int i=0;i<n;i++)
{
s.pb(ii(a[i],b[i]));
}
sort(s.begin(),s.end());
int ptr=0;
priority_queue <int> pq;
bool flag=0;
for(int i=0;i<M;i++)
{
while(ptr<n && s[ptr].first<=K[i])
{
pq.push(-s[ptr].second);
ptr++;
}
while(pq.size() && -pq.top()<K[i])
{
pq.pop();
}
for(int j=0;j<K[i];j++)
{
if(pq.empty())
{
flag=1;
break;
}
pq.pop();
}
if(flag)
{
break;
}
}
if(flag)
{
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... |