USACO Gold 2015 December - Fruit Feast

Authors: Danh Ta Chi Thanh, Mark Phan

Official Analysis (Java)

C++

#include <bits/stdc++.h>
using namespace std;
bool dp[2][5000001];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
freopen("feast.in","r",stdin);
freopen("feast.out","w",stdout);
int T,A,B;

Alternative Implementation - BFS

C++

#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e6 + 5;
bool pass[maxn][2];
struct node {
int val;
bool drunk;
};

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!