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>
#include "teams.h"
using namespace std;
vector< int > usefulPerson;
vector< int > A;
vector< int > B;
int N;
void init(int n, int a[], int b[]) {
N = n;
A.resize(n);
B.resize(n);
for(int i = 0; i < n; i++){
A[i] = a[i];
B[i] = b[i];
}
}
bool comp(pair< vector< int >, int > &Aa, pair< vector< int >, int > &Bb){
return Aa.first.size() < Bb.first.size();
}
bool comp1(int &a, int &b){
return usefulPerson[a] < usefulPerson[b];
}
int can(int M, int K[]) {
usefulPerson.assign(N,0);
vector< pair< vector< int >, int > > work(M);
for(int i = 0; i < N; i++){
for(int j = 0; j < M; j++){
work[j].second = j;
if(A[i] <= K[j] && B[i] >= K[j]){
usefulPerson[i]++;
work[j].first.push_back(i);
}
}
}
for(int i = 0; i < M; i++){
sort(work[i].first.begin(), work[i].first.end(),comp1);
}
sort(work.begin(), work.end(),comp);
vector< bool > USED(N);
for(int i = 0; i < M; i++){
int rem = K[work[i].second];
int curr = 0;
while(rem && curr < (int)work[i].first.size()){
curr++;
if(USED[work[i].first[curr-1]]){
continue;
}
USED[work[i].first[curr-1]] = true;
rem--;
}
if(rem) 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... |