Problems

Pick a problem and write your solution in the built-in editor. The judge runs it against real test cases while you watch, and the wider archive is open to read whenever you like.

Total results3,683 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Stock MarketFind the contiguous subarray with the largest sum and report its 1-based start and end indices, breaking ties by smallest start then smallest end.Medium5Dynamic programmingGreedyNo attempts yet1s256 MBJudgeable
Venus RoverChoose which stones to collect so total value is maximized, given limits on time and total lifted mass.Medium5Dynamic programmingNo attempts yet1s128 MBJudgeable
FashionistaFor each day pick any clothing whose temperature range covers that day's high, maximizing the sum of absolute flashiness differences between consecutive days.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
JOI FlagCount fillings of an M by N grid with J, O, I (some cells fixed) that contain at least one L shape: J with O to its right and I below, modulo 100000.Medium5Dynamic programmingCombinatorics+2No attempts yet5s128 MBJudgeable
Commute RouteCount monotone lattice paths from (1,1) to (w,h) that never turn at two consecutive intersections, modulo 100000.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
StrollSimulate the letters on a grid as N successive walks from the top-left, and report the endpoint of the N-th walk.Medium5SimulationDynamic programming+1No attempts yet2s128 MBJudgeable
Longest Common SubstringGiven two uppercase strings of length up to 4000, find the length of the longest substring that occurs contiguously in both.Medium5Dynamic programmingString+2No attempts yet2s256 MBJudgeable
FloodgatesEach gate drains Fi per hour at fixed cost Ci when opened. For each query (V, T), find the minimum total cost whose combined capacity Fi*T covers V.Medium5Brute forceGreedy+2No attempts yet1s128 MBJudgeable
Child PlayGiven domino-like slabs, orient and order them so both rows sum equally, discarding one slab only if necessary and preferring the smallest minimum half.Medium5Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
SupermarketGiven a shopping list and products in path order, buy the list items in order from later positions at minimum total cost, or report impossible.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
Milk SchedulingGiven task durations and precedence constraints that form a DAG, find the minimum makespan when unlimited workers milk cows in parallel.Medium5GraphTopological sort+2No attempts yet1s128 MBJudgeable
BookshelfPartition the books in order into shelves whose widths sum to at most L, minimizing the total of each shelf's maximum height.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
Hay For SaleGiven a wagon capacity and a list of hay bale volumes, find the largest total volume not exceeding the capacity that can be formed by choosing whole bales.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
Cow Digit GameFor each starting number, players alternately subtract its largest or smallest nonzero digit, and the player who reaches 0 wins; decide if the first player wins.Medium5Dynamic programmingGame theory+2No attempts yet1s128 MBJudgeable
Cow CashCount the number of unordered ways to make an amount N using V coin denominations, where each coin can be used any number of times.Medium5Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable
Charm BraceletChoose a subset of N charms, each with a weight and a desirability, so that total weight stays within M and total desirability is maximized.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
Cow ContestGiven the winners of head-to-head matches, count how many cows have a skill rank that is fully forced by the results.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
Cow TravellingCount the number of walks of exactly T steps on a grid from a start cell to a target cell, where each step moves to a vertically or horizontally adjacent open cell.Medium5Dynamic programmingMatrix+2No attempts yet1s128 MBJudgeable
ATM PIN TheftGiven a sequence of observed key presses (digits and at most one backspace), count the four-digit PINs that could produce exactly that sequence of pressed keys.Medium5Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
Hopeless CoachGiven past win, draw, and loss counts, find the probability that the team earns at least P points over the next N matches.Medium5Dynamic programmingProbability+2No attempts yet1s128 MBJudgeable
String ComputerCompute the minimum number of single-character insert, delete, or change operations needed to turn one string into another.Medium5Dynamic programmingString+2No attempts yet1s128 MBJudgeable
Extrapolation Using a Difference TableExtend a sequence by k steps using a polynomial difference table, always assuming the highest-order differences stay constant, and print the (n+k)-th term.Medium5MathDynamic programming+2No attempts yet1s128 MBJudgeable
El DoradoCount the increasing subsequences of length exactly k in a sequence of n distinct numbers, for several test cases.Medium5Dynamic programmingArray+1No attempts yet1s128 MBJudgeable
A Game with MarblesEach move takes one marble from a bowl and, if it is not bowl 1, adds one marble to every lower-numbered bowl; count the total moves until all bowls are empty.Medium5Dynamic programmingMath+1No attempts yet1s128 MBJudgeable
France '98Given win probabilities for every pair of 16 teams and a fixed bracket, compute each team's probability of winning the single-elimination tournament.Medium5Dynamic programmingProbability+2No attempts yet1s128 MBJudgeable
Humble NumbersFor each n up to 5842, print the nth number whose only prime factors are 2, 3, 5, or 7, formatted with the correct English ordinal suffix.Medium5Dynamic programmingMath+2No attempts yet1s128 MBJudgeable
Spiderman's WorkoutAssign plus or minus signs to the distances so the partial sums stay at or above 0 and return to 0 at the end, minimizing the peak height.Medium5Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
Median Weight BeadGiven weighted comparisons between beads, count how many beads cannot be the median because at least (N+1)/2 beads are known heavier or lighter.Medium5GraphDFS+2No attempts yet1s128 MBJudgeable
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