Official Analysis (C++)

Video Solution

Note: The video solution might not be the same as other solutions. Code in C++.

Implementation

Time Complexity: O((2N+CN)N)\mathcal{O}((2^N+CN)N)

C++

#include <bits/stdc++.h>
using namespace std;
int N, L;
vector<vector<int>> schedule;
vector<vector<vector<int>>> next_show;
vector<int> length;
vector<pair<int, int>> dp;
Code Snippet: bit operations (Click to expand)

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!