USACO Bronze 2016 February - Load Balancing
Authors: Maggie Liu, Kevin Sheng
C++
Implementation
#include <algorithm>#include <cstdio>#include <iostream>#include <set>#include <vector>using namespace std;int main() {freopen("balancing.in", "r", stdin);
Java
import java.io.*;import java.util.*;public class Balancing {public static void main(String[] args) throws IOException {BufferedReader read = new BufferedReader(new FileReader("balancing.in"));StringTokenizer initial = new StringTokenizer(read.readLine());int cowNum = Integer.parseInt(initial.nextToken());// We won't use this variableint maxPos = Integer.parseInt(initial.nextToken());
Python
with open("balancing.in") as read:# max_pos won't be usedcow_num, max_pos = [int(i) for i in read.readline().split()]x_vals = []y_vals = []v_fence = set()h_fence = set()for _ in range(cow_num):x, y = [int(i) for i in read.readline().split()]
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!