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,689 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Run, RunFind the maximum distance covered in N minutes of running and forced resting under a fatigue cap M, using dynamic programming over run-rest blocks.Medium6Dynamic programmingPrefix sum+1No attempts yet2s128 MBJudgeable
Garden PruningFind the minimum number of edge cuts needed to prune a tree down to exactly m vertices while keeping it connected.Medium6Dynamic programmingTree+1No attempts yet2s128 MBJudgeable
Strange KeyboardGiven a string on a cursor-based keyboard, find the minimum Left/Right/Enter presses needed to print every character in alphabetical order.Medium6Dynamic programmingGreedy+2No attempts yet2s128 MBJudgeable
Making a RectangleGiven up to 16 sticks, choose four disjoint groups forming two equal-length pairs of sides to maximize the rectangle's area, or return -1 if impossible.Medium6Bit manipulationDynamic programming+2No attempts yet2s256 MBJudgeable
Painting RoofsGiven a tree of houses and M paint costs, assign a color to every house minimizing total cost so that adjacent houses have different colors.Medium6Dynamic programmingTree+2No attempts yet2s128 MBJudgeable
Turning Off the LightsGiven a row of L bulbs and a fixed T-slot switch device that can be pressed at any aligned position any number of times, find the minimum number of bulbs left on.Medium6Dynamic programmingBit manipulation+2No attempts yet2s128 MBJudgeable
Partitioning for Fun and ProfitGiven m, n and k, output the k-th lexicographically smallest partition of m into n non-decreasing positive parts.Medium6CombinatoricsDynamic programming+2No attempts yet2s128 MBJudgeable
HarvestFind the maximum weighted profit from repeatedly harvesting a plant from either end of a row, where each harvest's value is multiplied by its pick order.Medium6Dynamic programmingArray+1No attempts yet1s128 MBJudgeable
Counting Full Binary TreesCount full binary trees with exactly n nodes and height exactly k, modulo 9901, using a height-bounded DP and subtraction trick.Medium6Dynamic programmingTree+2No attempts yet2s128 MBJudgeable
Word GameGiven a string and a dictionary of words, find the minimum number of characters to delete from the string so the rest is a concatenation of dictionary words in order.Medium6Dynamic programmingString matching+2No attempts yet2s128 MBJudgeable
Rock-Paper-ScissorsCompute, as a reduced fraction, the probability that Hangseung reaches K round wins before Dongju in at most N rounds of rock-paper-scissors with ties possible.Medium6Dynamic programmingProbability+1No attempts yet2s128 MBJudgeable
Dice Battle GameGiven a defender count, simulate probabilistic dice battles to find the minimum starting attacker count achieving at least 50% win probability.Medium6Dynamic programmingProbability+1No attempts yet2s128 MBJudgeable
Greedy PandaFind the longest strictly increasing path through adjacent cells in an n x n grid using memoized DFS.Medium6DFSDynamic programming+1No attempts yet2s256 MBJudgeable
Critical PathOn a DAG, find the longest path length from source to target, then count edges that lie on at least one such longest path.Medium6Dynamic programmingTopological sort+1No attempts yet2s512 MBJudgeable
Excellent VillagesGiven a tree with village populations, choose a maximum-weight independent dominating set (no two chosen villages adjacent, every unchosen village adjacent to a chosen one).Medium6Dynamic programmingTree+1No attempts yet2s128 MBJudgeable
RaceGiven n checkpoints with scores that must be visited in increasing index order from and back to the origin, find the maximum score achievable within a runner's distance budget, for multiple runners.Medium6Dynamic programmingGeometry+1No attempts yet1s128 MBJudgeable
Longest Arithmetic ProgressionGiven up to 2000 nonnegative integers, find the maximum size subset that can be reordered into an arithmetic progression.Medium6Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
Largest L ShapeGiven a binary grid, find the maximum-area L-shape (union of two rectangles sharing a lower-left corner, wider base and taller top) made entirely of 1-cells.Medium6Dynamic programmingMatrix+1No attempts yet2s128 MBJudgeable
Unsweet CookieChoose up to K starting points for length-D intervals over a timeline to cover the maximum number of given points.Medium6GreedyBinary search+1No attempts yet2s512 MBJudgeable
Atomic EnergyGiven a forest built from energy-state vertices connected by edges whose weight equals a proton energy, pick an independent set of vertices maximizing the sum of values (weighted maximum independent set on a forest).Medium6Dynamic programmingTree+1No attempts yet2s128 MBJudgeable
Multiplication GameDetermine, given a real number X and up to 6 multiplier cards at most 0.9, which player forces X below or equal to 1 first under optimal play.Medium6Game theoryMath+1No attempts yet2s128 MBJudgeable
Card GameGiven 9 piles of 4 cards, compute the probability that repeatedly removing a uniformly random matching-rank pair of top cards clears all cards.Medium6ProbabilityDynamic programming+1No attempts yet2s128 MBJudgeable
ElevatorChoose elevator stop floors in a 31-story building to minimize the last employee's arrival time, given elevator move/stop costs and stair costs.Medium6Dynamic programmingGreedy+1No attempts yet2s128 MBJudgeable
Water Pipe ConstructionSelect a subset of pipes with lengths summing exactly to D that maximizes the minimum capacity among chosen pipes.Medium6Dynamic programmingGreedy+1No attempts yet2s128 MBJudgeable
Palindrome PartitionGiven a lowercase string up to length 2000, find the minimum number of palindromic substrings it can be partitioned into.Medium6Dynamic programmingStringNo attempts yet2s128 MBJudgeable
CiphertextGiven up to 40 positive integers and a target K, find a subset (as a bitstring) whose sum equals K, exploiting the small total sum with meet-in-the-middle or subset-sum search.Medium6Dynamic programmingBit manipulation+1No attempts yet2s128 MBJudgeable
Number of MultisetsGiven multiplicities of values from 1 to T among A numbers, count multisets of size K for S≤K≤B modulo 1,000,000.Medium6Dynamic programmingCombinatorics+1No attempts yet2s128 MBJudgeable
Shortest Uncommon SubsequenceGiven two strings, compute the length of the shortest subsequence of A that is not a subsequence of B.Medium6Dynamic programmingStringNo attempts yet2s128 MBJudgeable
Stacking DiceGiven N dice with fixed opposite-face pairs, choose orientations so that stacked dice match top-to-bottom faces and maximize the sum of one vertical column of side numbers.Medium6Dynamic programmingSimulation+1No attempts yet2s128 MBJudgeable
Robot NavigationGiven an N x M grid, find the maximum sum path from top-left to bottom-right moving only left, right, or down without revisiting cells.Medium6Dynamic programmingMatrix+1No attempts yet1s512 MBJudgeable
Palindrome PathsCount length-L walks on an N x N grid with 8-directional moves whose visited digit sequence forms a palindrome.Medium6Dynamic programmingMatrix+1No attempts yet2s128 MBJudgeable
Reasonable PathsGiven a weighted undirected graph, count paths from vertex 1 to vertex 2 where each step moves to a vertex strictly closer to vertex 2 by shortest-path distance.Medium6Shortest pathGraph+1No attempts yet2s128 MBJudgeable
Molecule DecompositionFind the minimum number of edge cuts on a tree needed to isolate a connected subtree of exactly M nodes.Medium6TreeDynamic programming+1No attempts yet2s128 MBJudgeable
Find the K-th Pinary NumberGiven K up to 10^18, output the K-th smallest binary string with no leading zero and no two consecutive 1s, treated as a number by value order.Medium6Dynamic programmingCombinatorics+1No attempts yet2s128 MBJudgeable
Divide IntervalsSelect exactly M non overlapping, non adjacent intervals from an array of up to 100 integers to maximize the total sum.Medium6Dynamic programmingArrayNo attempts yet2s128 MBJudgeable
GPS EncodingGiven a letter permutation encoding numbers 0-25, find the shortest way to encode a digit string as letters using single digits or valid two-digit pairs, breaking ties by lexicographically largest result.Medium6Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Making a TriangleGiven up to 40 sticks, partition all of them into three groups whose summed lengths form a triangle, maximizing the triangle's area via Heron's formula.Medium6Dynamic programmingCombinatorics+1No attempts yet2s128 MBJudgeable
ChopsticksGiven N chopstick lengths, pick 3K of them and group into K triples to minimize the sum of squared differences between the two smallest lengths in each triple.Medium6Dynamic programmingSorting+1No attempts yet2s128 MBJudgeable
Mole CatchingGiven N moles with positions and appearance times, find the maximum number Jeongeun can catch by moving at speed at most S from origin at time 0.Medium6Dynamic programmingSorting+1No attempts yet2s128 MBJudgeable
Safe Drop TestGiven N floors and K identical safes, compute the minimum number of drops needed in the worst case to find the critical breaking floor.Medium6Dynamic programmingBinary search+1No attempts yet2s128 MBJudgeable
Death NoteGiven word lengths that must be placed in order into fixed-width rows with single spaces between words, minimize the sum of squared leftover cells for all rows except the last.Medium6Dynamic programmingGreedyNo attempts yet2s128 MBJudgeable
Monodigital ExpressionCompute, for repeated digit K and concatenations plus arithmetic operators, the minimum number of K digits needed to build each queried integer (or report NO if it exceeds 8).Medium6Dynamic programmingMath+1No attempts yet2s128 MBJudgeable
Base StationsGiven points off a line, place axis-aligned squares centered on the x-axis to cover all points while minimizing the total side length sum.Medium6Dynamic programmingSorting+2No attempts yet2s128 MBJudgeable
Seat ArrangementCount the ways to seat N-1 ticket holders into N seats, given one free seat, so that each person sits in their own, adjacent, or the free seat.Medium6Dynamic programmingCombinatorics+1No attempts yet2s128 MBJudgeable
GeneFind the maximum-length subsequence of a DNA string that can be built by the given nested and concatenated matching-pair grammar (like balanced parentheses with a/t and g/c pairs).Medium6Dynamic programmingStringNo attempts yet2s128 MBJudgeable
String ReconstructionCount length-L strings over an alphabet such that every length-k substring belongs to a given allowed set, solved via automaton/DP over overlaps.Medium6Dynamic programmingString+1No attempts yet2s128 MBJudgeable
Word ChainGiven up to 16 vowel-only words, chain them by matching first and last letters without repeats to maximize the total length used.Medium6Bit manipulationDynamic programming+1No attempts yet2s128 MBJudgeable
Minimum Edit Distance 2Compute the minimum number of insert, delete, replace, and adjacent-swap operations to transform string X into string Y.Medium6Dynamic programmingStringNo attempts yet2s128 MBJudgeable
Team Running SelectionSelect a subset of students whose heights sum exactly to H while maximizing the minimum running speed among chosen members.Medium6Dynamic programmingBinary search+1No attempts yet2s128 MBJudgeable
Phone Number MnemonicsFind the minimum number of dictionary words whose digit encodings concatenate to exactly match a given phone number, using the letter to digit telephone mapping.Medium6Dynamic programmingString matching+1No attempts yet2s128 MBJudgeable
Survival and EscapeChoose for each time-ordered box whether to eat it for HP or stack it for height, to survive as long as possible while reaching stack height D as early as possible.Medium6Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
FarmerGiven a budget Q of cypress trees selectable from cyclic gardens and linear furrows, maximize total olive trees gained where a full garden gives n olives but a partial selection from a garden or any furrow segment gives one less than the count chosen.Medium6Dynamic programmingGreedyNo attempts yet2s128 MBJudgeable
Making Numbers EqualGiven a line of n numbers, compute the minimum number of block-increment operations (merging equal adjacent runs) needed to make all elements equal.Medium6Dynamic programmingArray+1No attempts yet2s128 MBJudgeable
Distances Between Leaf VerticesGiven consecutive-leaf distances of an inorder-numbered binary tree, compute the distance between two arbitrary leaves using a sparse-table style max-range query derived from LCA depth relations.Medium6TreeSegment tree+1No attempts yet2s128 MBJudgeable
Collecting ItemsCount monotone right/up paths from bottom-left to top-right on a grid that must pass through every item cell and avoid obstacle cells.Medium6CombinatoricsDynamic programming+1No attempts yet2s128 MBJudgeable
Sua's Candy BasketsGiven baskets on a line each decaying one candy per time unit, find the maximum total candy collectible starting from position 0 with optimal movement order.Medium6Dynamic programmingGreedy+1No attempts yet1s512 MBJudgeable
Piggy BanksGiven N, choose the order of incrementing two counters from (1,1) to (N,N) so that concatenating the pair as a number gives a prime as often as possible, and output the maximum count.Medium6Dynamic programmingMath+1No attempts yet1s128 MBJudgeable
2012 End of the WorldGiven N, P, V, find the minimum total time to reduce N members to one opinion via recursively splitting into groups that each meet at cost k*P+V.Medium6MathDynamic programming+1No attempts yet1s128 MBJudgeable
BulbsGiven N colored bulbs where changing one bulb also flips its contiguous same-colored neighbors, find the minimum number of changes to make all bulbs one color (classic zuma-like merging interval DP).Medium6Dynamic programmingArrayNo attempts yet1s128 MBJudgeable
Grid GameGiven an M×N grid of black and white stones, compute the minimum number of monochromatic-region flood-fill flips needed to make the whole grid one color.Medium6BFSGraph+1No attempts yet2s256 MBJudgeable
Pebble Game of ChanceCount the sequences of N wheel spins whose cumulative pebble cost never exceeds K, modulo 42043.Medium6Dynamic programmingMath+1No attempts yet1s128 MBJudgeable
Rescuing the PrincessCount round trips from Yusi Island to Hooper Island and back on a line, using each island's directional-strength springboard at most once except the start, modulo 1000.Medium6Dynamic programmingArray+1No attempts yet1s128 MBJudgeable
Exhibition HallOrder stacked paintings of equal width but different heights front to back to maximize the total price of paintings whose exposed visible height is at least S.Medium6GreedySorting+1No attempts yet1s256 MBJudgeable
Rotating Dining TableGiven three ordered dish requests on a rotating table shared by father, mother, and Hyeon at fixed offsets, find the minimum total rotation steps to satisfy all sequences.Medium6Dynamic programmingSimulation+1No attempts yet1s128 MBJudgeable
Food ChainGiven N intervals, find the longest chain where each interval strictly contains the next (with ties allowed on one endpoint), essentially a longest chain problem solvable via sorting and LIS-style binary search.Medium6Binary searchSorting+1No attempts yet1s256 MBJudgeable
Social Network ServiceGiven a friendship tree, find the minimum dominating set size so every non-selected person has all neighbors selected.Medium6TreeDynamic programming+1No attempts yet3s256 MBJudgeable
Switches and BulbsGiven two orderings of numbers 1..N, find the longest set of wires that pairwise don't cross, which reduces to longest increasing subsequence with reconstruction.Medium6Dynamic programmingBinary search+1No attempts yet1s128 MBJudgeable
Board GameGiven a colored card sequence and a colored graph, find a walk starting at village 1 that uses cards in order to maximize color matches with traversed roads.Medium6Dynamic programmingGraph+1No attempts yet1s128 MBJudgeable
DNA SimilarityFind substrings of two DNA sequences that maximize a local sequence-alignment score with custom match and mismatch/gap penalties, and output the score and substrings.Medium6Dynamic programmingStringNo attempts yet1s128 MBJudgeable
Small LocomotivesChoose three disjoint consecutive-car segments (each up to a fixed length) from a train to maximize total passengers carried.Medium6Dynamic programmingPrefix sum+1No attempts yet1s128 MBJudgeable
Police CarsAssign a sequence of incidents to one of two police cars moving along Manhattan-distance shortest paths so that total travel distance is minimized, and output the assignment.Medium6Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Car Race MaintenanceGiven a maximum travel range and per-station maintenance times, select a minimum-cost subset of stations so consecutive gaps never exceed the range, and output the chosen stations.Medium6Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Build the Tallest TowerSelect and order bricks with strictly increasing area and weight from bottom to top to maximize total height, then output the chosen brick indices top to bottom.Medium6Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
Maximum Cycle Value of 1Given n and k, count permutations of 1..n whose cycle containing element 1 has maximum element exactly k.Medium6CombinatoricsMath+1No attempts yet1s128 MBJudgeable
Recursive Palindrome PartitionsCount recursive palindrome partitions of N, where a partition is valid if it is a palindrome and both halves are recursively valid.Medium6Dynamic programmingRecursion+2No attempts yet1s128 MBJudgeable
Tile FillingCount the number of ways to tile a 4×N board with 2×1 dominoes for multiple queries, bounded so the answer fits in a 32-bit integer.Medium6Dynamic programmingMath+1No attempts yet1s128 MBJudgeable
Press to UnlockCount the number of ordered sequences of disjoint nonempty subsets (a set partition of any subset of buttons into an ordered sequence of blocks) for given B up to 11.Medium6CombinatoricsMath+1No attempts yet1s128 MBJudgeable
Childhood Toy BoxesCount subsets of N boxes (as bitmasks over M<=20 toy types) whose union covers all M types, modulo 1e9+7.Medium6Bit manipulationDynamic programming+2No attempts yet2s128 MBJudgeable
DNA DiscoveryGiven a binary string, find the minimum number of single-character flips or whole-prefix flips needed to turn every character into A.Medium6GreedyDynamic programming+1No attempts yet1s128 MBJudgeable
Conveyor BeltGiven worker base times and car complexities on a pipelined assembly line, compute the minimum total completion time respecting sequential handoff constraints.Medium6Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Counting Pipe InstallationsCount the ways to lay a single connected pipe path with six pipe shapes from the top-left entry to the bottom-right exit through a grid with blocked cells, modulo 10007.Medium6Dynamic programmingMatrix+1No attempts yet2s128 MBJudgeable
Difficulty-Based Problem SelectionCount ways to pick exactly one problem per difficulty level 1..N given fixed-difficulty and flexible dual-difficulty problem pools, modulo 1e9+7.Medium6Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable
Nikola's JumpsFind the minimum-cost path to square N where forward jumps grow by 1 each time and backward jumps match the last forward jump length.Medium6Dynamic programmingGraph+1No attempts yet1s128 MBJudgeable
BirthdayGiven N intervals, find and print the longest chain of distinct intervals where each contains the next one.Medium6Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
Digit Sum in an IntervalCount integers in [A,B] with a given digit sum and output the smallest such integer, for bounds up to 10^15.Medium6Dynamic programmingMath+1No attempts yet1s128 MBJudgeable
Valid Bracket StringsCount ways to replace question marks in a bracket string with one of three bracket types so it becomes a valid nested bracket sequence, output last five digits.Medium6Dynamic programmingStringNo attempts yet1s128 MBJudgeable
ConfusionCount permutations of 1..N with exactly C inversions, modulo 1e9+7, using DP with prefix sums for the given constraints.Medium6Dynamic programmingPrefix sum+1No attempts yet1s128 MBJudgeable
Counting Bicycle Race RoutesCount directed paths from village 1 to village 2 in a graph, printing the last 9 digits or 'inf' if a reachable cycle makes the count infinite.Medium6Topological sortDynamic programming+1No attempts yet1s128 MBJudgeable
Agent Mission AssignmentGiven an N x N matrix of success percentages, assign one mission per agent to maximize the product of chosen probabilities, essentially an assignment problem with a product (log-sum) objective.Medium6Dynamic programmingBit manipulation+1No attempts yet1s128 MBJudgeable
Number of PlusesCount all plus-shaped patterns of odd size at least 3 in an N x N binary matrix, where every cell outside the cross must be 0.Medium6Dynamic programmingMatrix+1No attempts yet1s128 MBJudgeable
Dot Matrix PrinterGiven a string, find the minimum number of SET/NEXT/WRITE printer commands needed to output it, where NEXT temporarily overrides the next WRITE.Medium6Dynamic programmingString+1No attempts yet1s128 MBJudgeable
Apples and BananasFind a monotone down/right/diagonal path in an RxC grid to maximize apples below plus bananas above it, with R,C up to 1500.Medium6Dynamic programmingMatrix+1No attempts yet1s256 MBJudgeable
Hangman GameGiven a hidden word, find the order to select each distinct letter starting from A on a circular alphabet dial that minimizes total LEFT/RIGHT/OK button presses.Medium6Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
Word DivisionCount the number of ways to split a long word (up to length 300,000) into consecutive substrings all belonging to a dictionary of up to 4000 short words, modulo 1337377.Medium6Dynamic programmingString matching+2No attempts yet1s128 MBJudgeable
Minimum Trailing Zeros PathFind a path from top-left to bottom-right of an N×N grid, avoiding zero cells, that minimizes trailing zeros in the product of visited cells.Medium6Dynamic programmingMatrix+1No attempts yet1s128 MBJudgeable
HugoGiven N tree positions with scheduled apple-fall times, find the maximum number of apples a character starting at the middle square (moving at most one square per second) can catch.Medium6Dynamic programmingGreedy+1No attempts yet2s128 MBJudgeable
Two Subsequences 2Given two strings A and B of length up to 2000, find the shortest string that is a subsequence of A but not a subsequence of B.Medium6Dynamic programmingString+1No attempts yet1s128 MBJudgeable
Mirko's Newspaper TimeGiven jobs with start times and durations that Mirko must greedily choose among on tie-starts while never queuing missed jobs, maximize total idle (newspaper) minutes over the shift via optimal choice, essentially a DP over time with tie-breaking.Medium6Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
ShelvesGiven required shelf positions in a grid, choose one ladder placement height per column to minimize the total summed climbing height covering each object from its column or adjacent columns.Medium6Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Arranging CardsGiven C≤4 colors with N cards each in a hand sequence, find the minimum number of single-card moves to reach some arrangement where colors form contiguous ascending-value blocks in any color order.Medium6Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable