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;
struct fenwick_tree_2d{
map<int,int>data[500100];
} T;
int N_;
vector<pair<int,int>>stuff;
void init(int N, int A[], int B[]) {
N_=N;
for(int i=0;i<N;i++)
stuff.push_back({A[i],B[i]});
sort(stuff.begin(),stuff.end());
}
int dobig(map<int,int>mp){
int pos=0;
priority_queue<int>pq;
for(auto[i,x]:mp){
while(pos<N_&&stuff[pos].first<=i)
pq.push(-stuff[pos++].second);
while(pq.size()&&-pq.top()<i)
pq.pop();
while(x--){
if(pq.empty())return 0;
pq.pop();
}
}
return 1;
}
int can(int M, int K[]) {
map<int,int>REQ;
int SM=0;
for(int i=0;i<M;i++) SM+=K[i],
REQ[K[i]]+=K[i],SM=min(N_+1,SM);
if(SM>N_) return 0;
return dobig(REQ);
}
# | 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... |