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 <bits/stdc++.h>
using namespace std;
const int MAX_N = 500000 + 10;
const int MAX_M = 500000 + 10;
int bk_sz;
int M , K[MAX_M];
int N , A[MAX_N] , B[MAX_N];
void init(int N0 , int A0[] , int B0[]) {
N = N0;
for(int i = 0; i < N; i++) {
A[i] = A0[i];
B[i] = B0[i];
}
bk_sz = (int)sqrt(N);
}
int solve1() {
priority_queue<int> pq;
vector<pair<int,int> > v_pii;
for(int i = 0; i < N; i++) v_pii.push_back(make_pair(A[i] , B[i]));
sort(v_pii.begin() , v_pii.end());
for(int i = 0 , j = 0; i < M; i++) {
while(!pq.empty() && pq.top() < K[i]) pq.pop();
while(j < N && v_pii[j].first == i) pq.push(v_pii[j++].second);
int x = K[i];
while(x && !pq.empty()) {
pq.pop();
x--;
}
if(x) return 0;
}
return 1;
}
int can(int M0 , int K0[]) {
M = M0;
for(int i = 0; i < M; i++) K[i] = K0[i];
sort(K , K + M);
return solve1();
}
# | 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... |