USACO Silver 2020 January - Berry Picking

Authors: Qi Wang (Java), Daniel Suh (C++)

Official Analysis

Time Complexity: O(max(Bi)NlogN)\mathcal{O}(max(B_i) \cdot N\log N)

C++

//C++ Solution by Daniel Suh
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mpa make_pair
#define pb push_back

Java

//Created by Qi Wang
import java.util.*;
import java.io.*;
public class berries {
static int N, K;
static int[] B;
public static void main(String[] args) throws IOException {
InputReader in = new InputReader("berries.in");
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("berries.out")));

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!