Curated sets

Dynamic programming ladder

Every judgeable DP problem, easiest first.

All problems
Total results3,128 problems
TopicsJudge
Choose Your Own ArithmeticGiven working digits and exactly W add-or-multiply steps applied left to right from a single digit, decide whether each target value is reachable.Medium5Brute forceDynamic programming+2No attempts yet2s512 MBJudgeable
NukitGiven counts of particles A, B, C, D, two players alternately remove one of five fixed multisets; find who wins under optimal play.Medium5Game theoryDynamic programming+2No attempts yet1s128 MBJudgeable
Super PlumberFind the maximum total coin value on a path from the bottom-left to the bottom-right of a grid where SP moves right, up, or down without revisiting cells.Medium5Dynamic programmingImplementationNo attempts yet1s128 MBJudgeable
King Thrór's GoldCount the ways to choose exactly k distinct bar values summing to T, and list all solutions in lexicographic order when there are at most 20.Medium5Dynamic programmingBacktracking+2No attempts yet1s128 MBJudgeable
The Millionaire and the OrphansGiven three orphanages with fixed basket areas and children counts, compute the expected total gift value each orphanage catches as gifts are thrown in order.Medium5ProbabilityMath+1No attempts yet1s1024 MBJudgeable
Wooden SticksGiven n sticks with length and weight, order them to minimize the number of setup steps, where a setup is needed unless both length and weight are nondecreasing from the previous stick.Medium5SortingGreedy+1No attempts yet1s128 MBJudgeable
InvestmentStarting capital grows over at most 40 years by rebuying a portfolio of bonds each year; maximize the final amount.Medium5Dynamic programmingGreedyNo attempts yet1s128 MBJudgeable
DivisibilityGiven a sequence and a modulus K, decide whether some choice of + or - before each later element makes the total divisible by K.Medium5Dynamic programmingMath+2No attempts yet1s128 MBJudgeable
RelocationSplit up to 10 furniture items between two cars with capacity limits so that every item gets moved in the fewest number of paired trips.Medium5Dynamic programmingBinary search+2No attempts yet1s128 MBJudgeable
Balanced ChangeGiven counts of five coin types in a drawer and an amount, choose coins to give out so that the imbalance of the remaining coins is minimized.Medium5Dynamic programmingBrute force+1No attempts yet1s128 MBJudgeable
Betting SetsPartition an N by M table of probabilities into groups of one cell per column to maximize the expected number of all-heads groups.Medium5Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
Apocalyptic AlignmentGiven two A/B strings of equal length, find the minimum number of operations that repaint a contiguous segment with one fruit type to turn the first string into the second.Medium5Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Game DiceGiven up to 13 dice with various face counts and a target total, compute the probability of rolling exactly that sum, to five decimals.Medium5Dynamic programmingProbability+1No attempts yet1s128 MBJudgeable
FootballGiven pairwise win probabilities, find the team most likely to win a fixed single-elimination bracket of 2^n teams.Medium5Dynamic programmingProbability+1No attempts yet1s128 MBJudgeable
Three Bit ComputerGiven a string over {a,b,c}, decide whether an all-uninitialized memory can be initialized to exactly that string with the two given operations.Medium5Dynamic programmingGreedyNo attempts yet1s32 MBJudgeable
Digit Sum Over a RangeGiven l and u up to 2e9, find the total of the digit sums of every integer in that inclusive range.Medium5MathDynamic programming+2No attempts yet1s128 MBJudgeable
No Pause TelegraphGiven a string of dots and dashes and seven fixed letter codes, split it into codewords that minimize the resulting message alphabetically, or report that no split exists.Medium5Dynamic programmingString+2No attempts yet1s128 MBJudgeable
PearlsGiven demand and price per pearl for classes in increasing quality order, find the cheapest way to buy all pearls when each class's order may be upgraded to a higher class, paying 10 extra pearls' worth per purchase.Medium5Dynamic programmingPrefix sum+1No attempts yet1s128 MBJudgeable
Afternoon TeaTrack the tea and milk levels in a cup over a sequence of half drinks and refills, and report which ingredient was consumed more.Medium5Dynamic programmingMath+1No attempts yet3s32 MBJudgeable
Chocolate WholesalerGiven n independent bars with individual surprise probabilities, find the probability that a carton has at least k surprises.Medium5ProbabilityDynamic programmingNo attempts yet1s128 MBJudgeable
Cash DispenserCount 4-digit PINs whose digits appear as a subsequence of every recorded finger-movement sequence.Medium5StringDynamic programming+1No attempts yet3s128 MBJudgeable
PassageSplit n people into groups whose total weight is at most W, minimizing the sum of each group's slowest crossing time.Medium5Dynamic programmingBit manipulation+1No attempts yet3s128 MBJudgeable
ProtocolsCount the length-m strings over k symbols with no run of l equal symbols, then output floor((n/m) * log2(count)).Medium5Dynamic programmingCombinatorics+2No attempts yet3s128 MBJudgeable
BalanceGiven weights, split some into two equal-sum disjoint groups; find the largest weight that can be the heaviest used one.Medium5Dynamic programmingSorting+2No attempts yet3s128 MBJudgeable
BitmapFor each black pixel in an n by m bitmap, output the Manhattan distance to the closest white pixel.Medium5BFSGraph+1No attempts yet1s128 MBJudgeable
The Number of N-k-special SetsCount subsets of {1,...,n} with no two consecutive numbers whose sum exceeds k, for n up to 100.Medium5Dynamic programmingCombinatoricsNo attempts yet1s128 MBJudgeable
Building BlocksRemove blocks from a tower so the most remaining blocks sit at an altitude equal to their printed number.Medium5Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
ElectricityGiven k lines between n homes and m windmills on parallel lines, count subsets of non-crossing lines where every home and windmill has degree at most one, modulo r.Medium5Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
DiceFind the k-th non-decreasing sequence of length m with values from 1 to n, in lexicographic order.Medium5CombinatoricsDynamic programming+2No attempts yet1s128 MBJudgeable
MatchesFlip the fewest matches in a row so fire lit at the left end spreads through every neighboring pair.Medium5Dynamic programmingPrefix sumNo attempts yet1s512 MBJudgeable
Raffle TicketsBuy tickets from baskets with known winning and losing counts to guarantee at least g wins with the fewest tickets.Medium5Dynamic programmingNo attempts yet1s128 MBJudgeable
WatchtowersFind the maximum sum over any nonempty block of consecutive towers arranged in a circle.Medium5Dynamic programmingArrayNo attempts yet1s128 MBJudgeable
KonkotenacjaCount the ways to split the word into nonempty pieces joined by the literal separator kot, modulo 1000000007.Medium5Dynamic programmingPrefix sum+1No attempts yet2s128 MBJudgeable
SalesmenGiven a graph and a reported vertex sequence, find the fewest entries to change so consecutive vertices stay put or follow an edge.Medium5Dynamic programmingGraphNo attempts yet1s128 MBJudgeable
Graceful Prime DecompositionCount ordered sums of N from primes up to K where no two neighboring primes are equal.Medium5Dynamic programmingNumber theoryNo attempts yet1s128 MBJudgeable
TaekwondoSort both weight lists and pair players to minimize the total absolute weight difference across all matches.Medium5Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
Message BroadcastingCompute the fewest rounds to spread a message from the root when each informed node calls at most one child per round.Medium5GreedyTree+2No attempts yet1s128 MBJudgeable
Servicing ClientsChoose clients whose distance-times-demand costs fit the budget to maximize total priority.Medium5Dynamic programmingShortest pathNo attempts yet1s128 MBJudgeable
Tug of WarDecide whether N student weights (4 to 30) split into two teams whose total strengths differ by at most X.Medium5Dynamic programmingNo attempts yet1s128 MBJudgeable
Tiling Up BlocksFind the largest subset of blocks that stacks so both knob counts never decrease from bottom to top.Medium5Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
Project staffingAssign at most n hired workers to m projects so the total expected profit from rewards, fines, and conditional wages is maximal.Medium5Dynamic programmingProbability+1No attempts yet1s128 MBJudgeable
77377Split a digit string into dictionary words whose telephone-keypad encoding matches each segment.Medium5Dynamic programmingTrie+1No attempts yet1s128 MBJudgeable
Nested Shrubbery BoxesChoose the largest subset of boxes that nest when every box is rotated to fit strictly inside the next box.Medium5Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
Family TreesEach person lists two parents, so answer each query with the inherited share one person contributes to another as a reduced fraction, or report no relation.Medium5GraphDynamic programming+1No attempts yet1s128 MBJudgeable
Reconstructing the Longest Common SubsequenceFind the length of the longest common subsequence of two uppercase strings and output the lexicographically smallest one.Medium5Dynamic programmingGreedyNo attempts yet0.1s256 MBJudgeable
PointsPick a subset of targets in a row to maximize the total where each picked target scores based on how many neighbors are also picked.Medium5Dynamic programmingNo attempts yet3s128 MBJudgeable
The Hopeless QueueCount fillings of the movable spots with equal coin totals so every prefix keeps at least as many 50 coins as 100 coins, modulo 1000000.Medium5Dynamic programmingCombinatoricsNo attempts yet2s128 MBJudgeable
Frozen SprinklersCut pipes with minimum total force so no water flows from the central node to any leaf sprinkler in the tree.Medium5Dynamic programmingTree+1No attempts yet3s128 MBJudgeable
Freeing Up CapacityChoose RAID-1 sets to convert so the gained capacity reaches e GB while the total size of converted sets is minimal.Medium5Dynamic programmingNo attempts yet2s512 MBJudgeable
Wrestling Team SelectionSplit up to 100 wrestlers into two teams of nearly equal size so the total weights differ as little as possible.Medium5Dynamic programmingNo attempts yet1s128 MBJudgeable
Prefix-Free SubsetsCount the subsets of the given word set in which no word is a prefix of another word.Medium5TrieDynamic programming+1No attempts yet1s128 MBJudgeable
Minimum Cost SortingFind the cheapest total of moved values needed to sort the array when moving one element to any position costs its value.Medium5Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
Cut the ListSplit the list into K consecutive pieces to minimize the sum of each piece's max minus min.Medium5Dynamic programmingIntervalsNo attempts yet2s128 MBJudgeable
Number of LocksCount length-n strings over heights 1 to 4 that use at least three distinct heights and have an adjacent pair differing by exactly 3.Medium5Dynamic programmingCombinatoricsNo attempts yet1s128 MBJudgeable
Tutor SimulationChoose a sequence of teaching, training, and book-buying actions within the time limit that maximizes final cash.Medium5Dynamic programmingBrute forceNo attempts yet2s512 MBJudgeable
InvestChoose one of five products to buy each month, respecting minimum holding periods, to maximize the total resale value at the end.Medium5Dynamic programmingNo attempts yet2s512 MBJudgeable
HoleFind the side length of the largest all-zero square in an n by n binary grid given by the positions of its ones.Medium5Dynamic programmingMatrixNo attempts yet2s512 MBJudgeable
The Umbrella ProblemEach turn the lemming steps one row down while laser beams rotate, and the task asks whether any grass square in the last row is reachable alive.Medium5Dynamic programmingSimulation+1No attempts yet1s128 MBJudgeable
Club ScheduleCount attendance and key-passing schedules over N days where each day's leader attends and the key stays with attendees.Medium5Dynamic programmingCombinatoricsNo attempts yet1s128 MBJudgeable
Shark TourSteer a car through a grid tunnel with blocked cells to collect the most sharks and print the tie-breaking action sequence.Medium5Dynamic programmingMatrixNo attempts yet1s256 MBJudgeable
Heracles and the Stables of AugeasPick rivers whose water totals at least W so the sum of straight-line digging distances from the stable is smallest.Medium5Dynamic programmingGeometryNo attempts yet1s256 MBJudgeable
Distinct Subarray GCDsCount the distinct GCD values taken over all contiguous subarrays for each test case.Medium5Number theoryDynamic programming+1No attempts yet5s256 MBJudgeable
EquatorEach test case gives city profits around a circle and asks for the most profitable contiguous block, or zero when all are losses.Medium5Dynamic programmingArrayNo attempts yet1s256 MBJudgeable
ShopsPick cells with no shared side in an N by 5 profit grid to maximize the summed profit.Medium5Dynamic programmingBit manipulationNo attempts yet2s256 MBJudgeable
Chomsky Normal Form GrammarDecide whether a given string of up to 1000 lowercase letters belongs to the language generated from start symbol S by a CNF grammar.Medium5Dynamic programmingIntervalsNo attempts yet5s256 MBJudgeable
Zeroing a Binary SequenceCount ordered flip sequences of exactly K moves that turn a given binary sequence into all zeroes.Medium5CombinatoricsDynamic programmingNo attempts yet1s256 MBJudgeable
Restaurant RatingsCount how many nonnegative score sheets rank no better than the given sheet under total sum first and critic order second.Medium5CombinatoricsDynamic programmingNo attempts yet1s256 MBJudgeable
Travel CardGiven daily bus and train ride counts, compute the cheapest mix of single fares and 1, 7, and 30 day bus and travel passes.Medium5Dynamic programmingPrefix sumNo attempts yet1s256 MBJudgeable
Narrow Art GalleryClose exactly k rooms with no row fully closed and no diagonal closures to keep the maximum total value of open rooms.Medium5Dynamic programmingNo attempts yet2s256 MBJudgeable
A Walk TogetherTwo walkers follow turn-by-turn routes on a grid, and you compute the most blocks they can walk together by waiting and matching identical directed blocks.Medium5Dynamic programmingSimulationNo attempts yet1s256 MBJudgeable
Cent SavingsSplit up to 2000 item prices in order into at most d+1 consecutive groups so the sum of each group rounded to the nearest 10 cents is smallest.Medium5Dynamic programmingPrefix sumNo attempts yet5s512 MBJudgeable
Super Pipes and Ant FeedingFind the smallest amount of liquid to pour into the root of a tree so percentage splits with optional squaring pipes still meet every leaf demand.Medium5Dynamic programmingTree+1No attempts yet1s32 MBJudgeable
Marathon 2Run checkpoints 1 to N in order while skipping at most K middle checkpoints to minimize total Manhattan distance.Medium5Dynamic programmingNo attempts yet1s256 MBJudgeable
Meeting TimeFind the smallest total travel time that both cows can achieve on separate downhill paths from field 1 to field N.Medium5Dynamic programmingGraphNo attempts yet1s256 MBJudgeable
Restore CalculationCount ways to fill each ? in equal-length strings A, B, and C with digits, leading digits nonzero, so A plus B equals C, modulo 1,000,000,007.Medium5Dynamic programmingMathNo attempts yet8s512 MBJudgeable
Two-Area DatabaseRead a fixed sequence of data kinds using a one-slot cache that loads at cost c and serves hits for free, and minimize total read cost.Medium5Dynamic programmingNo attempts yet1s256 MBJudgeable
Pi Day Pie DistributionCount the nondecreasing distributions of n pie pieces among k people with each person getting at least one piece.Medium5Dynamic programmingCombinatoricsNo attempts yet1s256 MBJudgeable
EmpireFind the fastest route from A to B whose total hull damage stays strictly below K.Medium5Shortest pathDynamic programmingNo attempts yet1s256 MBJudgeable
Honey Butter ChipArrange the M extra bags within the N fixed bags and pick no two adjacent bags to maximize the chip total.Medium5Dynamic programmingArrayNo attempts yet5s256 MBJudgeable
Square Piece CutCut an n by m integer-sided rectangle with guillotine cuts into the fewest integer-sided squares.Medium5Dynamic programmingNo attempts yet2s256 MBJudgeable
Card GameTwo piles of N cards are compared from the top, and the program finds the largest score earned by discarding a smaller right card.Medium5Dynamic programmingNo attempts yet1s256 MBJudgeable
Sequence ArtisanFind the largest product of any contiguous block in an array with values from -2 to 2, then report it modulo 1000000007.Medium5GreedyDynamic programming+1No attempts yet1s256 MBJudgeable
Traveling Salesman Tour 2Find the cheapest tour that starts at one city, visits each of N cities exactly once, and returns to the start using the given directed costs.Medium5Dynamic programmingBit manipulation+1No attempts yet2s256 MBJudgeable
Lucky Cookie BakeryAssign each dough ball to one of two ovens with different baking times to minimize the time the slower oven finishes.Medium5Dynamic programmingNo attempts yet5s128 MBJudgeable
Explosive MaterialsSplit conflicting materials into two safe boxes and minimize the fuller box size.Medium5GraphBFS+1No attempts yet3s256 MBJudgeable
The Missing PermutationFill the zeros with the missing values to maximize the length of the longest increasing subsequence.Medium5GreedyDynamic programming+1No attempts yet15s256 MBJudgeable
Attendance AwardCount length-N strings over L, O and A with at most one L and no three consecutive As for each N up to 3000.Medium5Dynamic programmingCombinatoricsNo attempts yet1s256 MBJudgeable
Longest Bitonic SubsequenceGiven a sequence of up to 1000 numbers, find the length of its longest subsequence that strictly rises then strictly falls.Medium5Dynamic programmingNo attempts yet1s256 MBJudgeable
Criboard Max APress A, select all, copy, and paste within N keystrokes to show the most As possible.Medium5Dynamic programmingNo attempts yet1s256 MBJudgeable
Football scorelinesCount the ordered scoring sequences by both teams that reach the given final score under the listed play values, modulo 1000000009.Medium5Dynamic programmingCombinatoricsNo attempts yet2s256 MBJudgeable
Vampire DiceCompute the success probability of scoring at least y points from x exploding ten-sided dice where 8 to 10 score and 10 grants an extra roll.Medium5ProbabilityDynamic programmingNo attempts yet1s256 MBJudgeable
TV WarPick non-overlapping weekly TV programs to maximize the total preference score.Medium5Dynamic programmingSorting+2No attempts yet1s256 MBJudgeable
RobberiesPick a subset of banks that maximizes the stolen money while the combined capture probability stays strictly below the given limit.Medium5Dynamic programmingProbabilityNo attempts yet1s256 MBJudgeable
Combat OddsGiven N independent battles with win chance p, compute the chance that a losing run of at least L occurs.Medium5ProbabilityDynamic programmingNo attempts yet1s256 MBJudgeable
CarrotFor each N, count the steps to reach zero by subtracting one when the pile splits into equal piles of at least two and subtracting two otherwise.Medium5Number theoryDynamic programmingNo attempts yet1s256 MBJudgeable
Atomic ComputerCount the length-y signed-binary strings over -1, 0 and 1 whose digits weighted by powers of two sum to x.Medium5Dynamic programmingBit manipulationNo attempts yet1s256 MBJudgeable
Gimli's GulletPack unlimited servings of M foods into capacity C for the most calories, breaking ties by the lexicographically smallest serving counts.Medium5Dynamic programmingNo attempts yet1s256 MBJudgeable
SurfPick waves with no wait-time overlap so the sum of fun points is as large as possible.Medium5Dynamic programmingSorting+1No attempts yet4s256 MBJudgeable
Feast CoinsCount ways to reach total S with owned coins so that every chosen coin value appears the same number of times.Medium5Dynamic programmingCombinatoricsNo attempts yet3s256 MBJudgeable
King's WalkMove a king n cells over a letter grid to match the motto in as many positions as possible, breaking ties by the smallest coordinate sequence.Medium5Dynamic programmingMatrixNo attempts yet1s256 MBJudgeable