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,705 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Digit DivisionCount the ways to split a digit string into contiguous blocks so each block is divisible by m, modulo 1e9+7.Medium7Dynamic programmingMath+1No attempts yet1s512 MBJudgeable
Amazing RaceChoose an order to visit task locations with service times, deadlines and travel times that fits in T minutes and earns the most points.Medium7Dynamic programmingBit manipulation+1No attempts yet5s256 MBJudgeable
Productivity improvementPartition all workers into exactly p nonempty lines to maximize the sum of each line's common overlapping work time.Medium7Dynamic programmingSorting+1No attempts yet2s256 MBJudgeable
DebuggingFind the single crashing line among n lines while balancing the cost of added print statements against the cost of each run.Medium7Dynamic programmingBinary searchNo attempts yet3s256 MBJudgeable
Game of CardsDecide the winner of a turn-based card game where each move trims one of many piles by up to K cards plus the value shown on the new top card.Medium7Game theoryDynamic programmingNo attempts yet1s256 MBJudgeable
AYBABTUYou cut k tree edges so each of the resulting k+1 regions holds a base and the total cut cost is smallest.Medium7Dynamic programmingTreeNo attempts yet10s512 MBJudgeable
PLAY in BASICGiven a Music Macro Language score, find the character length of the shortest score with identical pitches, note lengths, volumes, and rests.Medium7Dynamic programmingSimulation+1No attempts yet5s512 MBJudgeable
Three-way BranchCount three-way downward paths from (1,1) to (W,H) on a grid with up to 30 blocked cells, modulo 1000000009.Medium7Dynamic programmingMatrixNo attempts yet7s64 MBJudgeable
The Brothers GameEach turn the opponent picks a step count from three values and you walk exactly that many directed edges, racing to end a turn on node N in the fewest turns.Medium7Game theoryGraph+1No attempts yet2s256 MBJudgeable
Bringing Order to DisorderCount the n-digit strings that come before the given string ordered by digit sum, then shifted-digit product, then numeric value.Medium7Dynamic programmingCombinatorics+1No attempts yet1s256 MBJudgeable
Alpaca SentenceFind the K-th string in lexicographic order among the shortest palindromes that contain S as a subsequence, or report NONE.Medium7Dynamic programmingString+1No attempts yet3s256 MBJudgeable
Jumping JoeyA frog visits pads in order, pulls ropes to drag upcoming pads closer, jumps gaps up to D, swims the rest, and needs the fewest swims.Medium7Dynamic programmingGreedy+1No attempts yet3s256 MBJudgeable
Performance Assessment 2Find the shortest sequence over 1 to M that is not a subsequence of A and count such sequences modulo 1e9+7.Medium7Dynamic programmingGreedy+1No attempts yet1s256 MBJudgeable
Mario and the Evil ToadPick K distinct non-root nodes of a weighted tree and order them to maximize the round trip from the root through them in order.Medium7Dynamic programmingTree+1No attempts yet3s256 MBJudgeable
Martian KingAnswer rank, k-th, predecessor, and successor queries over the sorted binary color records of length-L routes from the capital to a regional center.Medium7Dynamic programmingBinary search+1No attempts yet2s256 MBJudgeable
CacheChoose which cached objects to evict for a known request sequence of sized objects with load costs to minimize total reload cost.Medium7Dynamic programmingBit manipulationNo attempts yet1s256 MBJudgeable
Energetic turtleCount right-and-down grid paths from (0,0) to (N,M) that step on at most T of the K trap cells, modulo Z.Medium7CombinatoricsDynamic programming+1No attempts yet2s256 MBJudgeable
K-th pathFind the K-th string in alphabetical order among all strings spelled by down-right paths from the top-left to the bottom-right of a letter grid.Medium7GreedyDynamic programmingNo attempts yet2s256 MBJudgeable
Beautiful rowCount distinct arrangements of the given numbers where every neighboring pair shares the same binary or ternary one-count.Medium7Dynamic programmingGraph+1No attempts yet3s256 MBJudgeable
BiochipsPick exactly M nodes from a rooted tree with given values so no picked node is an ancestor of another and the sum is maximal.Medium7Dynamic programmingTreeNo attempts yet2s512 MBJudgeable
K blocksSplit the array into exactly K contiguous blocks so the sum of each block's maximum is as small as possible.Medium7Dynamic programmingStack+1No attempts yet1s256 MBJudgeable
PinballThe program installs the cheapest set of row devices so every falling ball lands in one bottom cell.Medium7Dynamic programmingSegment treeNo attempts yet1s512 MBJudgeable
Angry CowsFind the smallest launch power whose chain of shrinking blast radii clears all hay bales on a line.Medium7Binary searchDynamic programming+1No attempts yet2s512 MBJudgeable
Circular BarnChoose up to k outer doors on a ring of n rooms so the total clockwise walking distance to every cow room is minimized.Medium7Dynamic programmingPrefix sumNo attempts yet2s512 MBJudgeable
Circular Barn RevisitedFarmer John opens k doors on a ring of n rooms so cows walking clockwise to their assigned rooms travel the smallest total distance.Medium7Dynamic programmingPrefix sum+1No attempts yet2s512 MBJudgeable
LandscapingMove, buy, or remove dirt so each of N flowerbeds reaches its target amount at minimum total cost.Medium7Dynamic programmingGraphNo attempts yet2s512 MBJudgeable
Albocede DNA (Small)Count subsequences of S that split into blocks of the form a^i b^j c^i d^j with i and j at least 1, modulo 1e9+7.Medium7Dynamic programmingString+1No attempts yet5s512 MBJudgeable
Divisor Erasing Game 2Given the board numbers, print for each possible first pick every reply that lets the second player force a win.Medium7Game theoryDynamic programming+1No attempts yet2s512 MBJudgeable
Costly Binary Search (Small)Find the comparison order that minimizes the worst-case total cost of locating the insertion position when each array slot has its own comparison cost.Medium7Dynamic programmingTree+1No attempts yet5s512 MBJudgeable
Runaway QuailCatch quails that flee in both directions on a line at given speeds by choosing the left-right chase order with the smallest total time.Medium7Dynamic programmingMathNo attempts yet5s512 MBJudgeable
Card GameBob repeatedly deletes three neighboring cards whose values form an arithmetic progression with difference K, and seeks the fewest cards that can remain.Medium7Dynamic programmingIntervalsNo attempts yet5s512 MBJudgeable
Card Game (Large)Repeatedly delete neighboring triples in arithmetic progression with difference K to leave as few cards as possible.Medium7Dynamic programmingIntervalsNo attempts yet5s512 MBJudgeable
Allergy Testing (Small)Kelly plans pooled food tests with different waits after negative and positive results to find her single allergy trigger in the fewest worst-case days.Medium7Dynamic programmingNo attempts yet5s512 MBJudgeable
Allergy Testing (Large)Find the shortest worst-case schedule of pooled food tests with asymmetric wait times that identifies the single allergen.Medium7Dynamic programmingBinary search+1No attempts yet90s512 MBJudgeable
ARAM (Small)Decide when to spend a capped, regenerating reroll budget on fresh random champions to maximize the long-run share of games won.Medium7Dynamic programmingProbability+1No attempts yet5s512 MBJudgeable
New Lottery Game (Large)Count pairs x below A and y below B whose bitwise AND is below K for up to 100 test cases.Medium7Dynamic programmingBit manipulationNo attempts yet5s512 MBJudgeable
Full Binary Tree (Large)Delete as few vertices as possible from a given tree so the survivors form a full binary tree with a freely chosen root.Medium7Dynamic programmingTree+1No attempts yet5s512 MBJudgeable
Let Me Tell You a Story (Small)Count the firing orders that delete ministers until the remaining pay sequence never rises down the ranks, modulo 10007.Medium7Dynamic programmingCombinatoricsNo attempts yet5s512 MBJudgeable
Observation WheelRandom arrivals fill the free gondolas of a circular wheel, and you compute the expected total of the distance-based fares.Medium7Dynamic programmingProbability+1No attempts yet5s512 MBJudgeable
Erdős and Szekeres Sequence ReconstructionRebuild the lexicographically smallest permutation of 1 to N whose increasing and decreasing subsequence lengths match the given arrays.Medium7BacktrackingGreedy+1No attempts yet5s512 MBJudgeable
Garbled EmailSplit the garbled string into dictionary words with changed letters spaced at least 5 apart while changing as few letters as possible.Medium7Dynamic programmingTrie+1No attempts yet60s512 MBJudgeable
Swinging WildDecide if vine-to-vine swings with grip limits can carry you from the first vine to the far ledge.Medium7GraphBFS+1No attempts yet5s512 MBJudgeable
Box Factory (Large)Match boxes and toys of equal type in order on run-length encoded lines to maximize the number of pairs.Medium7Dynamic programmingString matchingNo attempts yet5s512 MBJudgeable
Breaking Windows (Small)M workers randomly reinforce K windows and N villains randomly throw one stone each, and the task asks for the probability that at least one window breaks.Medium7ProbabilityCombinatorics+1No attempts yet5s512 MBJudgeable
Breaking Windows (Large)Compute the chance that random stone throws break at least one of K windows after random reinforcements raise their durability.Medium7ProbabilityCombinatorics+1No attempts yet30s512 MBJudgeable
Survivor (Large)Eat foods in expiry order so each meal starts before it spoils and the next meal follows after its satiation time to maximize total survival time.Medium7Dynamic programmingGreedy+1No attempts yet10s512 MBJudgeable
Children Wearing Hats (Small)Given hat totals, child count, and which child first knew its hat color, count the matching colorings modulo 32749.Medium7Game theoryDynamic programming+1No attempts yet5s512 MBJudgeable
Restoring the Erased Equation (Large)Fill every ? with a digit so the addition or subtraction holds without leading zeros and the whole equation is lexicographically smallest.Medium7Dynamic programmingGreedy+1No attempts yet5s512 MBJudgeable
Permutations with Equal RunsCount distinct rearrangements of each string that keep the original number of maximal blocks of equal letters, modulo 1000003.Medium7Dynamic programmingCombinatoricsNo attempts yet5s512 MBJudgeable
Letter Stamper (Small)Print a given string of A, B and C with push, pop and print on a letter stack using the fewest operations.Medium7Dynamic programmingStackNo attempts yet5s512 MBJudgeable
Letter Stamper (Large)Find the fewest stack pushes, pops, and prints needed to print each target string of A, B, and C grades in order.Medium7Dynamic programmingStackNo attempts yet15s512 MBJudgeable
City Tour (Small)Find the most vertices a single closed tour can visit when each street and point is used at most once in a city grown one triangle at a time.Medium7Dynamic programmingGraphNo attempts yet5s512 MBJudgeable
Candy Store (Small)Pick the fewest integer-weight boxes so up to k visitors, each asking 1 to C grams in unknown order, each receive an exact subset of the remaining boxes.Medium7Dynamic programmingGreedyNo attempts yet5s512 MBJudgeable
Travel PlanStarting from Earth, visit each of the N planets on a line exactly once, return to Earth, and burn the largest total distance within fuel F.Medium7Dynamic programmingBrute forceNo attempts yet5s512 MBJudgeable
FencePick the fewest boards from the given lengths of at most 100 so they sum to exactly L up to 1e18, or report IMPOSSIBLE.Medium7Dynamic programmingNumber theory+1No attempts yet5s512 MBJudgeable
Hot Dog Proliferation (Small)Vendors sharing a corner split one step east and one step west per move, and the task asks for the fewest moves that leave every vendor on a distinct corner.Medium7Dynamic programmingSortingNo attempts yet5s512 MBJudgeable
World Cup 2010 (Large)Pick the cheapest tickets in a knockout bracket so each team misses at most M[i] of the matches it plays, no matter who wins.Medium7Dynamic programmingTreeNo attempts yet5s512 MBJudgeable
Bacteria (Large)Given initially filled rectangles on a grid evolving by a north-west neighbor rule, compute the seconds until no bacterium remains.Medium7Dynamic programmingSimulation+1No attempts yet5s512 MBJudgeable
Load Testing (Small)For each case, compute the fewest adaptive load tests that guarantee bracketing the capacity within a factor of C in the worst case.Medium7Dynamic programmingBinary searchNo attempts yet5s512 MBJudgeable
Making Chess Boards (Large)Repeatedly cut the largest alternating-color square, breaking ties by topmost then leftmost position, and report how many boards of each size result.Medium7Dynamic programmingSimulation+1No attempts yet5s512 MBJudgeable
Your Rank is Pure (Small)Count subsets of 2 to n containing n whose repeated rank mapping stays inside the set until it reaches 1, modulo 100003.Medium7Dynamic programmingCombinatoricsNo attempts yet5s512 MBJudgeable
Your Rank is Pure (Large)Count the subsets of 2 to n that contain n and whose repeated rank mapping from n reaches 1.Medium7Dynamic programmingCombinatoricsNo attempts yet5s512 MBJudgeable
Make it Smooth (Large)Edit pixel values, delete pixels, or insert new ones at given costs so neighboring values differ by at most M for the lowest total price.Medium7Dynamic programmingMathNo attempts yet5s512 MBJudgeable
Doubly Sorted GridCount ways to fill a partially filled grid so rows and columns are non-decreasing, modulo 10007, with R and C at most 10.Medium7Dynamic programmingCombinatorics+1No attempts yet40s512 MBJudgeable
Alphabetomials (Large)Given a polynomial over 26 letter counts and a dictionary, sum its value over all phrases of 1 to K dictionary words, modulo 10009.Medium7Dynamic programmingCombinatorics+2No attempts yet5s512 MBJudgeable
Bribe the Prisoners (Small)Choose the release order of Q prisoners out of P cells to minimize total bribes, where each release bribes every still-occupied prisoner reachable from it until a boundary or empty cell.Medium7Dynamic programmingDivide and conquer+2No attempts yet5s512 MBJudgeable
Bribe the Prisoners (Large)Given prison cells in a row and a set of cells to release one per day, choose the release order that minimizes total bribes paid to prisoners who hear the news.Medium7Dynamic programmingDivide and conquer+2No attempts yet5s512 MBJudgeable
Collecting CardsEach pack is a uniformly random N-subset of C card kinds; find the expected number of packs until all C kinds are collected.Medium7Dynamic programmingProbability+1No attempts yet5s512 MBJudgeable
Collecting Every CardFind the expected number of booster packs to buy, each pack giving N distinct kinds, until all C kinds are collected.Medium7ProbabilityDynamic programming+2No attempts yet5s512 MBJudgeable
Mine Layer (Large)Given a Minesweeper-style grid of neighbor counts, find the maximum number of mines the middle row can hold in any layout that matches all counts.Medium7Dynamic programmingImplementation+1No attempts yet5s512 MBJudgeable
Rainbow TreesCount rainbow edge colorings of a tree where any two adjacent edges differ and any three consecutive edges all differ, modulo 1e9+9.Medium7TreeGreedy+2No attempts yet5s512 MBJudgeable
Mixing Bowls (Large)Given a recipe where each mixture's ingredients are other mixtures, find the minimum number of bowls needed to prepare it.Medium7TreeDFS+2No attempts yet5s512 MBJudgeable
Test Passing Probability (Small)With M submissions and Q questions of 4 choices each, find the maximum probability of answering every question correctly, learning only whether each submission passed.Medium7Dynamic programmingProbability+1No attempts yet5s512 MBJudgeable
Endless Knight (Large)Count right-and-down knight paths from (1,1) to (H,W) on a board up to 1e8 wide, avoiding at most 10 rocks, modulo 10007.Medium7Dynamic programmingCombinatorics+2No attempts yet5s512 MBJudgeable
CitiesGiven a weighted undirected graph, pick a minimum-cost set of edges so that all k special cities (k at most 10) end up in one connected component.Medium7Minimum spanning treeDynamic programming+2No attempts yet4s256 MBJudgeable
Heavenly Dragon FlashCount sequences of nondecreasing cut heights where each cut divides the object's height, modulo 1000000007.Medium7Dynamic programmingNumber theoryNo attempts yet2s128 MBJudgeable
My matrix multiplication travelogueGiven K, output dimension array a0..aN whose worst and best matrix-chain multiplication counts differ by exactly K, with the smallest lexicographic answer.Medium7Dynamic programmingMatrix+2No attempts yet1s128 MBJudgeable
AlchemyA product is a multiset of n ingredients chosen from m qualities; find the sum of the products of qualities over all such multisets, mod 1e9+7.Medium7CombinatoricsMath+1No attempts yet1s128 MBJudgeable
TorrentTwo computers start with a file in a tree; each minute, adjacent computers can copy in parallel subject to one copy per computer. Find the minimum minutes until all nodes have the file.Medium7TreeBFS+2No attempts yet2s512 MBJudgeable
Hide and Seek 2Find the minimum time for Subin to reach position K using steps of minus or plus 1 and doubling, plus the number of distinct shortest action sequences.Medium7BFSGraph+1No attempts yet2s512 MBJudgeable
Bribing the PrisonersRelease Q prisoners from a row of P cells in the order that minimizes bribes paid to neighbors reached by the news. Find that minimum total cost.Medium7Dynamic programmingIntervals+1No attempts yet2s512 MBJudgeable
Mutalisk 2Given up to 20 SCVs with health, each attack deals 9, 3, and 1 damage to three distinct SCVs; find the minimum number of attacks to destroy all of them.Medium7Dynamic programmingBit manipulation+1No attempts yet2s512 MBJudgeable
Distinct valid bracket subsequencesCount distinct non-empty balanced bracket strings that appear as subsequences of a given bracket string of length at most 100, modulo 1,000,000,007.Medium7Dynamic programmingString+2No attempts yet2s512 MBJudgeable
Coloring the BallsCount the sequences formed by drawing all balls from a box where the last ball of color 1 appears before the last of color 2, and so on.Medium7Dynamic programmingCombinatorics+1No attempts yet2s512 MBJudgeable
ZooCount assignments of N animals to two kinds so that the reported same-kind taller counts can be realized by some ordering of distinct heights.Medium7CombinatoricsDynamic programmingNo attempts yet2s512 MBJudgeable
Two WeightsGiven an undirected graph with two weights per edge, find the path from 0 to 1 minimizing the product of the two total weight sums.Medium7Shortest pathGraph+2No attempts yet2s512 MBJudgeable
KaraokeAssign each note of a sequence to one of two singers so that the total of the absolute pitch jumps within each singer's subsequence is minimized.Medium7Dynamic programmingArray+2No attempts yet2s512 MBJudgeable
Palindrome WalkGiven an undirected labeled graph, find the length of the shortest walk from vertex 0 to vertex 1 whose edge-label string is a palindrome, or -1 if none exists.Medium7BFSGraph+2No attempts yet2s512 MBJudgeable
Tournament winner placementsCount, over all N! seatings of N players in a fixed bracket, how many make each player the champion given a full win/loss table.Medium7Dynamic programmingCombinatorics+2No attempts yet2s512 MBJudgeable
Number lock 2Given two equal-length digit strings S and T, find the fewest moves to turn S into T where a move shifts any contiguous block of dials one step up or down modulo 10.Medium7Dynamic programmingGreedy+2No attempts yet2s512 MBJudgeable
Cutting TreesCut at most M trees per evening with distinct machines to exactly D_i meters, and find the minimum total height after T days.Medium7Dynamic programmingGreedy+1No attempts yet2s512 MBJudgeable
Scrooge Minho 2Given a tree with N cities, place the fewest police stations so that every city and every road is covered, where a station covers its city, its neighbors, and all incident roads.Medium7TreeDynamic programming+2No attempts yet2s512 MBJudgeable
Splitting a StringChoose K non-overlapping substrings of A that also appear in B in the same non-overlapping order, maximizing their total length.Medium7Dynamic programmingString+1No attempts yet2s512 MBJudgeable
Chains of MultiplesCount non-decreasing length-L sequences of values from 1 to N where in every pair one value divides the other, modulo 1e9+7.Medium7CombinatoricsDynamic programming+2No attempts yet2s512 MBJudgeable
Secret MissionGiven n candidates with talkativeness values, use at most s adjacent swaps to make the sum of the first k values as small as possible.Medium7Dynamic programmingGreedy+2No attempts yet2s512 MBJudgeable
Painting the BallsGiven M range-painting operations used in order with unknown colors, count how many distinct final black/white ball colorings are possible.Medium7Dynamic programmingBit manipulation+1No attempts yet2s512 MBJudgeable
Hongjun and AntimatterCount contiguous subarrays of length at least 2 that can be split into two disjoint nonempty parts with equal sums, modulo 1e9+7.Medium7Dynamic programmingPrefix sum+2No attempts yet2s512 MBJudgeable
Hongjun and the Tree 2Count the ways to cut edges of a tree so every remaining component has exactly one black vertex, modulo 1e9+7.Medium7TreeDFS+2No attempts yet2s512 MBJudgeable
Teams CreationCount the ways to partition n students into exactly k unnumbered teams so that any two teams are separated by a threshold on skill level.Medium7CombinatoricsSorting+2No attempts yet2s512 MBJudgeable
Maximal SumFor each query value b_j, find the maximum sum of a contiguous segment of a whose elements are all at least b_j, or 0 if none exists.Medium7SortingDivide and conquer+2No attempts yet2s512 MBJudgeable