# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1218546 | LIA | Teams (IOI15_teams) | C++17 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
static int n;
static vector<int> a, b;
void init(int _n, const vector<int>& _a, const vector<int>& _b) {
n = _n; a = _a; b = _b;
}
int can(int m, const vector<int>& k) {
vector<int> e(m);
for (int j = 0; j < m; j++)
for (int i = 0; i < n; i++)
if (a[i] <= k[j] && k[j] <= b[i])
e[j]++;
vector<int> pc(m), ap(n, -1);
for (int i = 0; i < n; i++) {
int bp = -1, bc = INT_MAX;
for (int j = 0; j < m; j++) {
if (a[i] <= k[j] && k[j] <= b[i] && e[j] < bc) {
bc = e[j];
bp = j;
}
}
if (bp != -1) {
ap[i] = bp;
pc[bp]++;
}
}
for (int j = 0; j < m; j++)
if (pc[j] != k[j]) return 0;
return 1;
}