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,688 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Turning Off the LampsGiven lamp positions and power rates on a line and a starting point, find the walking order that minimizes total energy spent before all lamps are switched off. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Moore MachineParse a series-parallel Moore machine expression and determine the unique erased output symbol that matches an observed string, or report ambiguity or impossibility. | Medium6 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| FATBOYFind the longest common subsequence of three given strings, breaking ties by lexicographically smallest result. | Medium6 | Dynamic programmingString | No attempts yet | 1s | 128 MB | Judgeable |
| A Huge TowerCount the number of orderings of N distinct blocks into a tower, respecting a size-tolerance stacking rule, modulo 1e9+9. | Medium6 | SortingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| MessengersGiven a tree with per-city messenger costs, compute for every city the minimum time to relay a message to the root via edge lengths and messenger switching costs. | Medium6 | TreeDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| BracketsCount, modulo 1e9+9, the ways to turn some matching '(' '(' pairs back into '[' ']' so the bracket string becomes valid with at least one square pair. | Medium6 | Dynamic programmingStack+1 | No attempts yet | 1s | 128 MB | Judgeable |
| MelodyGiven N notes with S-digit codes and a target tune of length L, choose a sequence of notes with adjacent Hamming distance at most G that minimizes total mismatch with the written tune, then output the smallest such sequence lexicographically. | Medium6 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| CandiesGiven N bags of candies, choose which bag's count to replace with a new positive value so the number of distinct subset sums is maximized, breaking ties by smallest P then smallest Q. | Medium6 | Dynamic programmingBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| RectanglesChoose an orientation (width/height swap) for each rectangle placed side by side to maximize the sum of top and internal vertical edges excluding outer sides and bottoms. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Speed LimitsFind the fastest path in a directed road network where roads without a posted speed limit inherit the previously used speed limit, requiring state-dependent shortest path search. | Medium6 | Shortest pathGraph+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ExpressionsCount balanced parenthesis strings of a given total length that have exactly a given maximum nesting depth. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Justice for AllGiven a k x k 0/1 trust matrix (k up to 20), count the number of perfect matchings between knights and horses, i.e. the permanent of the matrix. | Medium6 | Dynamic programmingBit manipulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Evacuation PlanGiven n team positions and m shelter positions on a line, find the minimum total distance assignment where every shelter gets at least one team. | Medium6 | Dynamic programmingSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Choosing a PubSimulate probabilistic vote-following among n pubs (Pólya urn style) to compute exact final probability each pub wins, handling ties uniformly. | Medium6 | Dynamic programmingProbability+1 | No attempts yet | 1s | 128 MB | Judgeable |
| TichuGiven a 13-card Tichu hand, compute the minimum number of legal combinations (singles, pairs, triples, quads, full houses, straights) that partition the hand. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Kim KangsanGiven fixed first and last pile heights, find the minimum total bricks added or removed to any middle pile so adjacent height differences stay within d. | Medium6 | Dynamic programmingArray+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Row and Column Deletion GameGiven an n x n matrix where players alternately remove the last row or column if its sum is even, determine which player wins with optimal play across possibly many test cases up to n=1000. | Medium6 | Game theoryDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The RobberyGiven N item types where type k has exactly k identical copies, pick copies within a weight budget M to maximize total value (bounded knapsack with huge M and small N). | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Computer TransformationGiven n up to 1000, compute the count of adjacent | Medium6 | MathString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| City GameGiven several grid maps of free and reserved cells, find the largest all-free rectangle in each grid and print its area times three. | Medium6 | StackDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| FirefightersDetermine if question-mark operators in an arithmetic expression with brackets can be replaced by +,-,*,/ to reach a given target value under integer truncating division. | Medium6 | Brute forceRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| BOATGiven clients in fixed order, each with rental durations and deadline-based payment options, schedule non-overlapping rentals to maximize total earned money. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Winning the MatchCompute the probability that team A wins a best-of-K volleyball match given per-serve win probabilities and a serve-switching rule between rounds and games. | Medium6 | Dynamic programmingProbability+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Reseller's EyeGiven a budget and multiple sellers each offering a fixed bundle of items (buy all or none), choose a subset of sellers within budget to maximize resale profit, a bundled knapsack problem. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Production ProcessGiven a matrix chain-like joining table for pieces, find the minimum-time parenthesization to assemble a given string, breaking ties by piece order. | Medium6 | Dynamic programmingString+1 | No attempts yet | 5s | 128 MB | Judgeable |
| Atomic Car RaceGiven checkpoints and a per-kilometer speed model that depends on distance since last tire change, find the tire-change strategy at checkpoints that minimizes total race time. | Medium6 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Confusing Login NamesCompute an extended edit distance (insert, delete, replace, adjacent swap) between all pairs of given login names and output pairs within a given threshold, sorted alphabetically. | Medium6 | Dynamic programmingString+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Random WalkGiven n steps with probabilities of moving left, right, or staying, compute the expected value of the maximum position reached. | Medium6 | Dynamic programmingProbability+1 | No attempts yet | 10s | 128 MB | Judgeable |
| Hongjun's Royal GuardCount permutations of N distinct elements where every interior element is a local extremum (both neighbors larger or both smaller); N is at most 20. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SightseeingChoose a direction for each track on a circular tour so the total hiking plus transfer time is minimized, and check it against a limit T. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cover UpGiven per-digit candidate lists with known-candidate probabilities, compute the win probability when the contestant plays optimally. | Medium6 | ProbabilityDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Pizza Delivery Minimum TimeGiven directed travel times between a pizzeria and up to 10 stops, find the shortest round trip from the pizzeria visiting every stop. | Medium6 | Shortest pathDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Two EndsFor each even-length row of cards, find the best score margin the first player can get when the second player always takes the larger end. | Medium6 | Dynamic programmingGame theory+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Sunday DriveGiven a sequence of straight and 90-degree curved highway sections with M lanes, find the shortest path including lane changes, which take 100 feet per lane. | Medium6 | Dynamic programmingGeometry | No attempts yet | 1s | 128 MB | Judgeable |
| Roller CoasterEach section of a roller coaster either adds fun and dizziness or reduces dizziness by K; find the maximum fun keeping dizziness at or below L at all times. | Medium6 | Dynamic programming | No attempts yet | 1s | 128 MB | Judgeable |
| The Ninja WayGiven trees in fixed left-to-right order with distinct heights, place them on integer positions so each jump to the next taller tree spans at most D, maximizing the span from shortest to tallest. | Medium6 | Dynamic programmingArray | No attempts yet | 1s | 128 MB | Judgeable |
| Robot ChallengeThe robot starts at (0,0), must visit targets in order, and may skip any target by paying its penalty. Find the minimum total time plus penalties to reach (100,100). | Medium6 | Dynamic programmingGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MosaicCount the tilings of an N x M grid with 2 x 2 squares and L-trominoes, modulo 1,000,000. | Medium6 | Dynamic programmingBit manipulation | No attempts yet | 1s | 128 MB | Judgeable |
| Class ScheduleChoose one class per category to minimize class costs plus total travel from position 0 through the chosen rooms to position L. | Medium6 | Dynamic programmingSorting | No attempts yet | 1s | 128 MB | Judgeable |
| Train SortingCars arrive in a fixed order; each can be attached to the front, the back, or skipped, keeping weights strictly decreasing front to back. Find the longest train. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TournamentGiven k knights with abilities, choose 2^e - k of them to sit out the first round and pair the rest to minimize the sum of squared ability differences. | Medium6 | Dynamic programmingSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Exchange RatesWith a daily CAD/USD rate and a 3% commission per conversion, find the maximum final amount of Canadian dollars you can hold after the last day. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Security CompanyPoints lie on a line with travel times between neighbors; starting from point a and visiting every point, minimize the total first-arrival time over all points. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| One Person “The Price is Right”Given G guesses and L lifelines, find the largest N such that a strategy guarantees a win for any price from 1 to N. | Medium6 | Dynamic programmingGame theory | No attempts yet | 1s | 128 MB | Judgeable |
| WFF 'N PROOFGiven counts of logic symbols, find the maximum length of a well-formed formula that can be built from a subset of them. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| A Walk Through the ForestCount the number of routes from intersection 1 to 2 in an undirected weighted graph where each step strictly decreases the shortest distance to intersection 2. | Medium6 | GraphShortest path+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Up the AnteGiven per-round win probabilities, find the chance a capped martingale strategy shows a positive balance at some round from k through m. | Medium6 | ProbabilityDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Work ReductionFor each agency with per-unit cost A and halving cost B, find the minimum cost to cut N units of paperwork down to exactly M. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Marbles on a TreeGiven a rooted tree where each vertex has a box and the total marbles equal the number of vertices, find the minimum number of moves (along edges) so every box holds exactly one marble. | Medium6 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Adventures in Moving - Part IVGiven a route with up to 100 gas stations, each with a price per litre, find the cheapest way to fuel a truck with a 200-litre tank that starts and ends half full. | Medium6 | GreedyDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| No TippingCount the orders in which n packages can be removed from a lever on two fulcrums so the board never tips. | Medium6 | BacktrackingBit manipulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Bridge CrossingGiven n people's crossing times and one flashlight, find the minimum total time to move everyone across when at most two cross together. | Medium6 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Brick Stops HereGiven N brick types with copper content and price, answer C queries: pick exactly M distinct types whose copper sum lies in [M*Cmin, M*Cmax] at minimum total price. | Medium6 | Dynamic programmingSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sang-geun's LockCount the number of height-balanced binary trees with N nodes, print the last 9 digits padded to width 9. | Medium6 | Dynamic programmingRecursion+1 | No attempts yet | 1s | 128 MB | Judgeable |
| PebblesPlace pebbles on an N by N board so no two touch even diagonally, maximizing the sum of covered cell values. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Words and the Periodic TableSplit each word into element symbols, case-insensitively, choosing the split with the fewest parts, then the lowest atomic-number sum. | Medium6 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| I'm Attacking the Darkness!Parse a dice expression with up to six dice and integer modifiers, then compute the reduced fraction of outcomes whose total meets or beats a target value. | Medium6 | Dynamic programmingProbability+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Time to GraduateGiven up to 12 courses with prerequisites, fall or spring offerings, and a per-semester course cap, find the minimum number of semesters to finish all courses. | Medium6 | GraphDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RobotsGiven garbage cells in a grid, robots walk from the northwest corner to the southeast corner moving only east or south; find the fewest robots that collect all garbage. | Medium6 | Dynamic programmingSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Raggedy, RaggedyGiven word widths and a max line length, split the words into lines and minimize the sum of squared unused space on every line except the last. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Not One Bit MoreCount integers in [LO, HI] whose repeated popcount chain reaches 1 at exactly step X, with LO up to 1e18 and X up to 10. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Roller CoasterChoose open or closed eyes for each roller coaster section to maximize total fun while keeping dizziness within limit L, where closing decreases dizziness by K. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| WordStackOrder the given words and pad each with leading spaces to maximize the total number of columns where a letter matches the letter directly above it. | Medium6 | Dynamic programmingBit manipulation | No attempts yet | 1s | 128 MB | Judgeable |
| The Candy StoreWith unlimited copies of each candy, find the maximum total calories obtainable with a given budget, where prices and the budget carry two decimal places. | Medium6 | Dynamic programmingImplementation+2 | No attempts yet | 3s | 512 MB | Judgeable |
| PillsCount how many distinct sequences of W and H can appear as a bottle of N pills is emptied, two halves per pill. | Medium6 | Dynamic programmingCombinatorics | No attempts yet | 1s | 256 MB | Judgeable |
| Vacation RentalsGiven a table of which units are free on each day, schedule a new guest's stay over [a,d) using the fewest unit changes, breaking ties by smallest unit label each night. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Toothpick ArithmeticFor each N up to 5000, find the fewest toothpicks needed to write an expression equal to N using unary operands and + or x as operators. | Medium6 | Dynamic programmingMath | No attempts yet | 1s | 128 MB | Judgeable |
| KnotsFor each even N up to 100, find the probability that two random perfect matchings on N points form a single cycle. | Medium6 | CombinatoricsMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Mix and BuildFind the longest sequence of given distinct words where each word is formed by adding one letter and rearranging. | Medium6 | Hash mapDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Chop Ahoy! Revisited!Count the ways to split a digit string into consecutive groups whose digit sums are non-decreasing across groups. | Medium6 | Dynamic programmingPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| Twirling RobotFind the cheapest sequence of override commands to steer a robot from the top-left cell to the bottom-right goal, where each cell forces a default move. | Medium6 | Shortest pathGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| DoormanGiven a queue of men and women and a limit X, repeatedly admit the front or second person so the running gender difference never exceeds X, and maximize the number admitted. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| JuiceGiven a rooted tree with cord capacities and house demands, choose which houses to power so that flow through each cord stays within capacity and the count is maximized. | Medium6 | TreeDFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Odd, Even, and ChangyeongThree players move in fixed order, each adding 1 or dividing by a prime, and each tries to minimize the smallest number they personally produce. | Medium6 | Dynamic programmingGame theory+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sanggeun Trapped in a MazeCount closed walks of length n on an infinite hexagonal lattice starting and ending at one room. | Medium6 | CombinatoricsDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Chemical AnalysisGiven up to 12 element bitmasks and a target bitmask, find the fewest elements whose bitwise OR equals the target, or report that none does. | Medium6 | Bit manipulationBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Monkeys at TypewritersGiven per-letter and space probabilities, find the probability that a random key sequence terminates at its first space in one of the given words. | Medium6 | ProbabilityTrie+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Zebra HerdAssign each of z zebras one of two colors at each of t times, minimizing same-color distance costs, opposite-color bonuses, and color-change penalties. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 7s | 128 MB | Judgeable |
| Arsenic and Old LaceGiven up to 20 base products as bitmasks over s substances, find the fewest products whose union exactly equals the poison mask, or report impossible. | Medium6 | Bit manipulationBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Swimming with SharksOn a w by h grid starting and ending at (1,1), plan t moves (or stays) to maximize the minimum Euclidean distance to any shark present at each time step. | Medium6 | Dynamic programmingBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Orange BowlGiven plays with a yard gain and success probability, choose a sequence whose total gain reaches n yards while maximizing the product of probabilities. | Medium6 | Dynamic programmingMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Course LoadPick a set of classes with pairwise disjoint meeting slots and total workload at most C, maximizing total utility. | Medium6 | Dynamic programmingBit manipulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Shut the Box IIGiven open cards and a rolled total, pick the set summing to the total that maximizes the probability of shutting every card under optimal play, and report that probability. | Medium6 | Dynamic programmingBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Buying NotebooksEach store has a fixed shipping fee, a per-notebook price, and limited stock; buy exactly N notebooks across stores at minimum total cost. | Medium6 | Dynamic programmingSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Digit Sum of a RangeFor each query [a,b] with b up to 10^15, output the sum of all decimal digits of every integer in the range. | Medium6 | MathDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Stifling the MutinyDistribute k pirates over n ships, each with at least one loyal pirate, so that no ship's loyal count is below the disloyal pirates on it and its neighbors, maximizing disloyal pirates. | Medium6 | Dynamic programmingBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| My Cousin ObamaGiven a forest of parent links, find the ancestor path from A0 to B0 that passes through as few mothers as possible. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RaisinsSplit an N by M chocolate bar into unit cells by straight cuts; each cut costs the raisins in the piece, and the goal is to minimize the total payment. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Average Value SequenceGiven a non-decreasing average sequence m of length n, count the integer sequences s of length n+1 whose adjacent averages equal m. | Medium6 | MathCombinatorics+2 | No attempts yet | 5s | 256 MB | Judgeable |
| Batch SchedulingSplit the ordered jobs into consecutive batches, each paying a setup time, and minimize the sum of weighted completion times. | Medium6 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| PalindromeGiven a string, find the minimum number of characters to insert anywhere so the string becomes a palindrome. | Medium6 | Dynamic programmingString+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Car ParkingGiven a row of cars and W workers, find the minimum number of cars that must change places so the types are sorted ascending. | Medium6 | GreedyDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Card Game is FunAnna may delete arbitrary cards from her sequence and Bruno may trim cards from the top and bottom of his; find the longest common subarray obtainable. | Medium6 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Used BookstoreChoose exactly K of N books to sell, maxing the total where selling t books of one genre adds t(t-1) extra to that genre's group. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| First GradeCount the ways to place + or - between the first N-1 digits and = before the last digit so that left-to-right evaluation never leaves the range 0 to 20 and the total equals the last digit. | Medium6 | Dynamic programmingArray | No attempts yet | 1s | 128 MB | Judgeable |
| Splitting the SnackChoose which of the N-1 cut points to cut so that both people get exactly N/2 pieces, minimizing the total force of the chosen cuts. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Hop-Hop River CrossingStarting from the near bank, hop across stones in n rows using normal jumps or at most m row-skipping jumps, minimizing total jump danger. | Medium6 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sea JourneyProcess a stream of queries where each query asks for the shortest path between two islands after a sequence of edge insertions. | Medium6 | Shortest pathGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Warp Speed IIFor each hop sequence, pick a warp-drive state per hop minimizing switch plus hop energy, and return the lexicographically smallest optimal state sequence. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Nowhere MoneyRepresent each amount as a sum of T(s) values (T(n) = Fibonacci-like count) with the fewest slots whose sizes differ by at least 2, and print the sizes and values. | Medium6 | GreedyDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |