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 <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <bitset>
// #include <numeric>
using namespace std;
int n;
vector<int> st[100010], en[100010];
int pt[100010];
bitset<100010> act;
vector<int> a, b;
void init(int N, int A[], int B[]) {
n = N;
a.resize(1), b.resize(1);
a.insert(a.end(), A, A + n);
b.insert(b.end(), B, B + n);
for(int i = 0; i < n; i++) st[A[i]].emplace_back(i + 1), en[B[i]].emplace_back(i + 1);
}
int can(int M, int K[]) {
long long sum = 0;
for(int i = 0; i < M; i++) sum += K[i];
if(sum > n) return 0;
for(int i = 1; i <= n; i++) pt[i] = 0, act[i] = 0;
for(int i = 0; i < M; i++) pt[K[i]] += K[i];
priority_queue<pair<int, int> > pq;
for(int i = 1; i <= n; i++){
for(auto &k : st[i]) pq.push({-b[k], k}), act[k] = true;
while(pt[i] && !pq.empty()){
int x = pq.top().second;
pq.pop();
if(!act[x]) continue;
act[x] = false;
pt[i]--;
}
if(pt[i] && pq.empty()) 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... |