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;
int n;
vector<int> smol, big;
int m;
vector<int> groups;
vector<vector<int>> tmp;
map<int, int> mp;
void init(int N, int* A, int* B){
n = N;
smol = vector<int>(n), big = vector<int>(n);
for(int i = 0; i<n; i++) smol[i] = A[i], big[i] = B[i];
tmp = vector<vector<int>>(n+1);
for(int i = 0; i<n; i++) tmp[big[i]].push_back(smol[i]);
for(int i = 1; i<=n; i++) sort(tmp[i].begin(), tmp[i].end());
}
int can(int M, int* K){
m = M;
groups = vector<int>(m);
for(int i = 0; i<m; i++) groups[i] = K[i];
mp.clear();
for(int i = 0; i<m; i++) mp[groups[i]] += groups[i];
for(int i = 1; i<=n; i++){
for(auto x : tmp[i]){
if(mp.empty()) return 1;
int num = (*mp.begin()).first;
if(num < x || num > i) break;
mp[num]--;
if(mp[num] == 0) mp.erase(num);
}
}
if(mp.empty()) return 1;
return 0;
}
# | 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... |