# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1154392 | Zheing | 팀들 (IOI15_teams) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "teams.h"
using namespace std;
int N;
vector<int> A, B;
void init(int n, vector<int> a, vector<int> b) {
N = n;
A = a;
B = b;
}
int can(int m, vector<int> K) {
int sum = 0;
for (int k : K) sum += k;
if (sum > N) return 0;
sort(K.begin(), K.end(), greater<int>());
vector<bool> assigned(N, false);
for (int k : K) {
int count = 0;
for (int i = 0; i < N; ++i) {
if (!assigned[i] && A[i] <= k && k <= B[i]) {
count++;
}
}
if (count < k) return 0;
int needed = k;
for (int i = 0; i < N && needed > 0; ++i) {
if (!assigned[i] && A[i] <= k && k <= B[i]) {
assigned[i] = true;
needed--;
}
}
}
return 1;
}