CF - Team Building

Authors: Sofia Yang, Kevin Sheng

Official Editorial (C++)

Implementation

Time Complexity: O(Np2p)\mathcal{O}(N\cdot p\cdot 2^p)

C++

#include <bits/stdc++.h>
using namespace std;
int main() {
int pool_size;
int team_size;
int aud_size;
cin >> pool_size >> team_size >> aud_size;
vector<pair<int, int>> aud_contrib(pool_size);
for (int i = 0; i < pool_size; i++) {

Java

import java.io.*;
import java.util.*;
public class TeamBuilding {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int poolSize = Integer.parseInt(st.nextToken());
int teamSize = Integer.parseInt(st.nextToken());

Alternate Solution

Minimum Cost Flow Solution

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!