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 results1,800 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Finding a Sequence from a Sign MatrixGiven the sign pattern of all subarray sums of a hidden integer sequence, reconstruct one integer sequence (values -10 to 10) that produces the same sign matrix. | Medium6 | Prefix sumMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| SoldiersMaintain unit sizes under point updates and answer queries for which unit contains a given soldier serial number using prefix sums. | Medium6 | Segment treeBinary search+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Picking Trash in the Same Increasing OrderFind the longest common strictly increasing subsequence of trash sizes recorded on two different days. | Medium6 | Dynamic programmingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| UndoSimulate a text editor whose undo command reverts every command from the previous t seconds, where undos themselves can be undone, and find the final text. | Medium6 | StackSimulation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Parliamentary ElectionGiven vote counts for N candidates, find the minimum number of voters candidate 1 must bribe so her total strictly exceeds every other candidate's total. | Medium6 | GreedyArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Character TrainingGiven character counts and power values per level, decide how to spend at most D training days across characters to maximize total power. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Card PlacementAssign N cards with numbers and letters to N ordered bins under a numeric constraint to build the lexicographically smallest string, or report impossibility. | Medium6 | GreedySorting+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Smallest RectangleFind the minimum area axis-aligned rectangle with integer coordinates whose strict interior contains at least half of N given points. | Medium6 | GeometryBrute force+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Artist Lee DonghoGiven a black/white grid and a limit on horizontal single-color brush strokes, find the minimum number of cells that end up unpainted or wrongly colored. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Morning Three and Evening FourGiven N banana weights, choose non-overlapping length-K blocks to move as a C-second group, minimizing total time and then the number of groups used, with output of chosen block positions. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Largest Zero SubmatrixGiven a binary matrix, find the maximum area rectangle of consecutive rows and columns that contains only zeros. | Medium6 | StackDynamic programming+2 | No attempts yet | 2s | 128 MB | Judgeable |
| HistogramGiven bar heights of a histogram, find the maximum-area rectangle that fits inside it using a stack-based approach. | Medium6 | StackArray+1 | No attempts yet | 0.7s | 128 MB | Judgeable |
| Making CouplesGiven lists of men's and women's personality values, form min(n, m) man-woman couples that minimize the total absolute difference of matched values. | Medium6 | Dynamic programmingSorting+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Maximum Submatrix SumGiven an N by M integer matrix, find the maximum possible sum over all contiguous rectangular submatrices. | Medium6 | Dynamic programmingMatrix+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Card BundlesGiven a shuffled permutation of 1 to N, output N-1 adjacent merges that combine bundles into a single bundle where each intermediate bundle holds consecutive integers. | Medium6 | StackGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Permutation RestorationGiven the inversion sequence of a permutation of 1..N, reconstruct the original permutation using an efficient data structure. | Medium6 | Segment treeBinary search+2 | No attempts yet | 0.55s | 128 MB | Judgeable |
| Adjacent MastermindGiven pairs of target and guess letter strings, compute black, grey, and white Mastermind scores by matching exact, then adjacent, then distant letters in priority order. | Medium6 | StringGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Bubble SortGiven an array, find the value of loop counter i when an early-exit bubble sort finishes sorting it. | Medium6 | SortingArray+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Array RotationGiven a target permutation of ±1..N reachable by repeated reverse-and-negate interval operations starting from the sorted array, output a sequence of such operations that produces it. | Medium6 | SimulationGreedy+1 | No attempts yet | 10s | 128 MB | Judgeable |
| Ball ReplacementSimulate a 4-slot cache using an eviction strategy (like Belady's algorithm) that minimizes total insertions and replacements while processing a sequence of digit cards. | Medium6 | GreedySimulation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Choosing a Subarray 2Find a contiguous subarray maximizing (sum of elements) times (minimum element), and output that maximum score with the interval bounds. | Medium6 | StackPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingGeometry+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Box PackingSimulate dropping same-width plates into a box using column-wise collision like Tetris, opening a new box when the drop would exceed the height limit, and report each box's final height. | Medium6 | SimulationArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Submatrix Range QueriesGiven an N x N matrix and K fixed-size BxB submatrix queries, output the max minus min value for each queried window efficiently. | Medium6 | Sliding windowMatrix+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Rectangles for Four FriendsGiven up to 500,000 distinct points, count axis-aligned rectangles with fixed side lengths A and B whose corners are all present in the point set. | Medium6 | Hash mapTwo pointers+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Choosing Points 2Given up to 100 points and a fixed rectangle width A and height B, find the placement that covers the maximum number of points, including boundary points. | Medium6 | ArraySorting+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Divide IntervalsSelect exactly M non overlapping, non adjacent intervals from an array of up to 100 integers to maximize the total sum. | Medium6 | Dynamic programmingArray | No attempts yet | 2s | 128 MB | Judgeable |
| MinesGiven N mines in a line with chain-reaction explosion rules based on impact strength, find the minimum set of mines to directly detonate so all mines explode. | Medium6 | GreedySimulation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Dumbbell SortingFind the minimum total cost of swaps (cost = sum of the two swapped weights) needed to sort an array of distinct weights into increasing order. | Medium6 | GreedySorting+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Mine RemovalGiven a grid with buildings, walls, and empty cells, choose bomb placements of a fixed blast radius so every empty cell is blasted without any blast touching a building. | Medium6 | SimulationGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Block StackingGiven max-per-row and max-per-column height arrays for a grid, determine feasibility and compute the minimum and maximum total block counts consistent with both views. | Medium6 | GreedyMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Similar PermutationGiven a permutation, construct the lexicographically smallest permutation where each position differs from the original by at most 1. | Medium6 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 512 MB | Judgeable |
| 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). | Medium6 | Dynamic programmingArray | No attempts yet | 1s | 128 MB | Judgeable |
| Arranging ShapesGiven a sequence of three shape types, compute the minimum swaps needed to group each type into one contiguous block, in any order of blocks. | Medium6 | Sliding windowGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| LockGiven the final arrangement after a left shift, a reversal of a subrange, and another left shift, recover valid parameters k, p, q, k that reproduce it. | Medium6 | ArraySimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Two ReversalsGiven a permutation of 1..N produced by two interval reversals of the sorted sequence, find two reversal operations that restore sorted order. | Medium6 | ArrayTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingBinary search+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Three ReversalsGiven an array formed by reversing three intervals of 1..N, find three interval reversals (with trivial ones allowed) that restore it to sorted order. | Medium6 | ArraySimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Electric Wires 2Given N wires between two poles, remove the minimum number of wires so the rest form an increasing sequence (longest increasing subsequence based removal), listing the removed A-positions. | Medium6 | Binary searchSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| IcebergSimulate yearly melting of an iceberg grid based on adjacent sea cells and find the first year it splits into multiple connected components, or 0 if it fully melts first. | Medium6 | SimulationBFS+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Small LocomotivesChoose three disjoint consecutive-car segments (each up to a fixed length) from a train to maximize total passengers carried. | Medium6 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Pizza SalesGiven two circular arrays of pizza-slice sizes, count ways to pick a contiguous arc from one pizza, from the other, or one arc from each, summing exactly to K. | Medium6 | Prefix sumHash map+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Total Area of Several RectanglesGiven up to 30 axis-aligned rectangles, compute the total area of their union. | Medium6 | GeometrySorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Making a Good ArrayCount pairs of indices to remove from an array so that the remaining elements have one value equal to the sum of the rest. | Medium6 | ArrayHash map+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Region FillingTrace region boundaries from direction strings, validate them for out-of-bounds moves, closure, and overlaps, then flood-fill each closed boundary with its letter. | Medium6 | SimulationImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Cipher Decoder Choi JunminFind the earliest starting word position in an encoded word sequence that matches a pattern sentence under a bijective word-to-word substitution mapping. | Medium6 | String matchingHash map+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Lucky WheelReconstruct the letters on a rotating wheel of N distinct-letter slots from a sequence of spin distances and resulting letters, or report impossibility. | Medium6 | SimulationArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Sum of Sequence ValuesGiven an array, compute the sum over all contiguous subarrays of (max - min) efficiently for up to 300,000 elements. | Medium6 | StackArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Pretty IndentationGiven current and target tab counts per line, find the minimum number of range increment/decrement operations to transform one array into the other, with the constraint that decrements can't push a value below zero. | Medium6 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ProgramSimulate marking multiples of several jump values into an array using a difference/counting trick, then answer many range-sum queries with prefix sums. | Medium6 | Prefix sumArray+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Snow White and the DwarfsGiven a sequence of hat colors and range queries, determine for each range whether a majority color exists and identify it. | Medium6 | Binary searchPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| RabbitsGiven a range update per day using sqrt-decomposition blocks with per-block cup counters and per-rabbit matchbox counters, report the sum of newly incremented counters each day. | Medium6 | Sliding windowImplementation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Number CircleGiven a circular array of sums of each element and its two neighbors, reconstruct one valid original positive-integer circular array. | Medium6 | MathSimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Oasis ReunionGiven a line of heights, count pairs who can mutually see each other using a monotonic stack while handling equal-height ties correctly. | Medium6 | StackArray | No attempts yet | 1s | 256 MB | Judgeable |
| New Array GameSupport left and right rotations on subarray ranges plus point queries on an array of up to 100,000 elements with up to 100,000 operations. | Medium6 | Segment treeArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingMatrix+1 | No attempts yet | 1s | 128 MB | Judgeable |
| MagnetsGiven N unit magnets that auto-merge based on adjacent poles, find the minimum number of flips needed to create a merged magnet of exact length L. | Medium6 | GreedySimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Grasshopper JumpsGiven a line of grasshoppers that repeatedly move by jumping left or right over B neighbors, report the maximum height jumped over for each move using an order-statistics/segment-tree-like structure over positions. | Medium6 | Segment treeArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Turbo ModeSimulate a TV remote where number keys change channels and repeated T presses cycle through a deduplicated history segment since the current channel's last appearance. | Medium6 | SimulationImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Restoring Sequence A from Sequence BReconstruct the lexicographically smallest permutation A of 1..N consistent with given prefix-set markers B and fixed positions, or report impossibility. | Medium6 | GreedyImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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 |
| 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 |
| Defense LineGiven an array, find the maximum length of a strictly increasing run achievable after deleting a single contiguous segment (possibly empty). | Medium6 | ArrayTwo pointers+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Copying BooksSplit a sequence of book page counts into k contiguous groups minimizing the maximum group sum, breaking ties by minimizing earlier scribes' loads first. | Medium6 | Binary searchGreedy+1 | 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 |
| ShuffleGiven a song-play log and playlist size s, count starting offsets that split the log into blocks of length s (first/last possibly shorter) with no repeated song inside any block. | Medium6 | Sliding windowArray+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 |
| Cubist ArtworkGiven front and side view maximum heights for a grid of cube piles, find the minimum total number of cubes consistent with both views. | Medium6 | GreedyMatrix+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Make a SequenceSimulate a 3D tic-tac-toe game with gravity-dropped balls and report the first move that completes an m-in-a-row across 13 directions, or a draw. | Medium6 | SimulationImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Suffix Array Re-constructionReconstruct a base string from partial suffix descriptions, where each suffix may contain one wildcard block, and decide when that is impossible. | Medium6 | StringImplementation+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Polar BearSimulate Conway's Game of Life on concentric rings with special opposite-cell neighbors, then report the live count and lexicographic first and last live cells after g steps. | Medium6 | SimulationArray+1 | No attempts yet | 5s | 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 |
| WiFiGiven house positions on a line and a budget of n access points, place them to minimize the maximum distance from any house to its nearest access point. | Medium6 | Binary searchGreedy+2 | 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 |
| BalanceGiven the polygon outline of a boat's side view, compute the centroid above and below the waterline and report whether the Center of Effort is forward, aft, or balanced, with the difference rounded to two decimals. | Medium6 | GeometryMath+2 | 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 |
| Pushing BoxesSimulate pushes of the four walls on unit boxes, stopping each wall when boxes are packed against the opposite wall, and report final positions sorted top-to-bottom, left-to-right. | Medium6 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Trip (2007)Given n bag sizes where a strictly smaller bag fits inside a larger one, find the minimum number of outermost pieces and then the smallest possible size of the largest nested piece. | Medium6 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Ultra-QuickSortGiven a sequence of distinct integers, count the minimum number of adjacent swaps needed to sort it, which is the number of inversions. | Medium6 | Divide and conquerSorting+2 | No attempts yet | 1s | 256 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 |
| 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 |
| Falling LeavesGiven the leaf-removal stages of a binary search tree, reconstruct the unique tree and print its preorder traversal. | Medium6 | TreeRecursion+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 |
| Iterated DifferenceFor each list, repeatedly replace every entry by the absolute difference with its cyclic successor and count iterations until all entries match, or report failure after 1000 steps. | Medium6 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Contour TracingTrace each 8-connected object's boundary with the Moore tracking algorithm and print the contour length, ignoring objects smaller than 5 pixels. | Medium6 | SimulationImplementation+2 | No attempts yet | 1s | 128 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 |
| Think I'll Buy Me a Football TeamGiven a matrix of inter-bank debts, compute the total cash needed to settle all debts and the minimum possible after netting and rerouting payments. | Medium6 | ArrayGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bread SortingDecide whether one permutation of 1..n can be turned into another using only the operation that rotates any three adjacent elements right by one. | Medium6 | ArrayGreedy+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 |
| Complaint SortGiven a sequence of n values, count the strictly decreasing subsequence triples (i < j < k with a_i > a_j > a_k). | Medium6 | ArrayCombinatorics+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Computer ScienceScore each page for a query word using occurrences in the page and in linking pages weighted by word distance to the hyperlink, then print the highest scoring pages. | Medium6 | ImplementationString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Volleyball ScoresGiven a sequence of ball touches, ground hits, and out of bounds calls, compute the volleyball score while checking that the correct team serves each volley. | Medium6 | SimulationImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| CubingSimulate a sequence of Rubik's cube face turns from a solved state and print the colors on the up face. | Medium6 | ImplementationSimulation+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 |