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 F first
#define S second
#define pb push_back
#define INF 99999999999999
#define all(x) x.begin(),x.end()
typedef long long ll;
ll n;
vector<ll>a;
vector<ll>b;
void init(int N, int A[], int B[])
{
n=N;
for(int i=0;i<n;i++)
{
a.pb(A[i]);
b.pb(B[i]);
}
}
int can(int M, int K[]) {
sort(K,K+M);
vector<pair<ll,pair<ll,ll>>>v;
for(int i=0;i<n;i++)
{
v.pb({a[i],{0,i}});
v.pb({b[i],{2,i}});
}
for(int i=0;i<M;i++)
v.pb({K[i],{1,0}});
sort(all(v));
vector<bool>vis(n,0);
priority_queue<pair<ll,ll>>pq;
bool tf=1;
for(auto x:v)
{
if(x.S.F==0)
pq.push({-b[x.S.S],x.S.S});
if(x.S.F==1)
{
ll curr=0;
while(!pq.empty() && curr<x.F)
{
while(!pq.empty() && vis[pq.top().S])
pq.pop();
if(!pq.empty())
{
curr++;
pq.pop();
}
}
//cout<<curr<<' '<<x.F<<',';
if(curr!=x.F)
{
tf=0;
break;
}
}
if(x.S.F==2)
vis[x.S.S]=1;
}
return tf;
}
# | 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... |