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 |
|---|---|---|---|---|---|---|
| Valid ArrayGiven a distinct integer array, find the minimum number of elements to add so it contains five consecutive integers. | Medium4 | ArrayBrute force+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Flammable Railway 997Given fireproof material amounts between train cars and a starting fire location, compute the time step when a target car explodes, or report it never does. | Medium4 | Prefix sumSimulation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Triangle BuilderGiven N straw lengths, pick three that form a triangle with the largest possible perimeter, or report -1 if none exist. | Medium4 | SortingGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Building Rest StopsGiven existing rest stops on a highway, place M new integer-position stops to minimize the longest gap between consecutive stops, found via binary search. | Medium4 | Binary searchGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Selling GoodsGiven each buyer's max price and delivery cost, choose a sale price (ties broken by lowest) that maximizes total profit summed over buyers who purchase profitably. | Medium4 | Brute forceSorting+2 | No attempts yet | 2s | 128 MB | Judgeable |
| GuitaristGiven a starting volume and a sequence of forced up/down changes bounded by [0, M], find the maximum achievable volume for the last song using reachability DP. | Medium4 | Dynamic programmingArray | No attempts yet | 2s | 128 MB | Judgeable |
| Bubble Sort Swap CountCount the number of adjacent swaps bubble sort performs to sort an array, equivalent to counting inversions efficiently. | Medium4 | SortingDivide and conquer+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Number of RoadsCount right/up lattice paths from (0,0) to (N,M) on a grid where certain unit edges are blocked by construction. | Medium4 | Dynamic programmingMatrix+1 | No attempts yet | 2s | 16 MB | Judgeable |
| Cable CuttingGiven K cable lengths, binary search the maximum integer cut length so that summing floor(length/cut) over all cables reaches at least N pieces. | Medium4 | Binary searchGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Magic Square RotationsGiven four fixed permutations that can be applied to an 8-number arrangement, find the minimum number of operations to reach a target arrangement from the initial one via BFS. | Medium4 | BFSSimulation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Same RemainderGiven a sequence, find the largest divisor D so that all numbers leave the same remainder when divided by D. | Medium4 | Number theoryMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Polynomial RemaindersCompute the remainder polynomial when dividing a given polynomial by x^k + 1, using the fact that x^k ≡ -1. | Medium4 | MathArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Center of SymmetryDecide whether a set of up to 10000 integer points has a center point such that every point's mirror image is also in the set. | Medium4 | Hash mapGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Partial SumFind the minimum length of a contiguous subarray whose sum is at least S, or 0 if none exists. | Medium4 | Sliding windowTwo pointers+1 | No attempts yet | 0.5s | 128 MB | Judgeable |
| CandyGiven the sums of adjacent candy counts for N students seated in an odd-sized circle, recover each student's exact candy count. | Medium4 | MathArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Box NestingFind the length of the longest strictly increasing subsequence of box sizes given in order. | Medium4 | Dynamic programmingBinary search+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Sum of Numbers 4Count the number of contiguous subarray sums of an array that equal a given target K, using prefix sums and a hash map. | Medium4 | Prefix sumHash map+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Matchstick GridGiven an ASCII 3x3 matchstick grid, count how many matchsticks were removed and how many complete squares of any size remain. | Medium4 | SimulationImplementation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Range Sum Query with UpdatesSupport point updates and range-sum queries on an array of up to a million integers using a Fenwick tree or segment tree. | Medium4 | Segment treeArray+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Sum of Numbers 7Support point updates and range sum queries on an array of up to 1,000,000 elements over up to 1,000,000 operations, requiring a Fenwick tree or segment tree. | Medium4 | Segment treePrefix sum+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Minimum and MaximumGiven N numbers and M range queries, output the minimum and maximum value within each query's index range. | Medium4 | Segment treeArray | No attempts yet | 2s | 192 MB | Judgeable |
| Maximum DistanceGiven up to 50,000 points, compute the maximum L1 (Manhattan) distance between any two of them. | Medium4 | MathGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Finding Silent IntervalsFind every starting index of a length-m window in an array where the max minus min value is at most c, using a sliding window with monotonic deques. | Medium4 | Sliding windowQueue+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Smallest Unmeasurable WeightGiven N integer weights usable only on one pan, find the smallest positive integer amount that cannot be formed as a subset sum. | Medium4 | GreedySorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Two Liquids Closest to ZeroGiven a sorted array, find two distinct numbers whose sum is closest to zero using a two-pointer sweep. | Medium4 | Two pointersArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Two LiquidsGiven N distinct integers, sort them and use two pointers to find the pair whose sum is closest to zero. | Medium4 | Two pointersSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Shuffle SequenceGiven a permutation of size N, compute the least common multiple of its cycle lengths, which is the number of shuffles needed to restore the original order. | Medium4 | MathArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| TowersFor each tower in a line, find the nearest tower to its left with height at least as large, using a monotonic stack approach. | Medium4 | StackArray | No attempts yet | 1.5s | 128 MB | Judgeable |
| Finding RegionsGiven a grid with several rectangles marked as blocked, find the number of connected empty regions and output their areas sorted ascending. | Medium4 | BFSArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Fire EnginesGiven sorted positions of pumps and fire engines on a line, assign each engine a distinct pump to minimize total distance connected. | Medium4 | GreedyDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Selecting NumbersGiven a functional graph i->A_i on 1..N, find the maximum set of indices closed under this mapping (union of cycles) and print it. | Medium4 | GraphArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Maximum Product of a Contiguous SubsequenceGiven N decimal numbers between 0.0 and 9.9, find the contiguous subsequence with the maximum product and print it rounded to three decimals. | Medium4 | Dynamic programmingArray | No attempts yet | 1s | 128 MB | Judgeable |
| Pancake FlippingSort a stack of N distinct pancakes into increasing order from top using prefix reversals, within a bound of 2N-3 flips. | Medium4 | GreedySimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Candy Sharing GameSimulate a circle of students repeatedly halving and passing candies right, rounding odd counts up, until all counts equalize, then report the round count and final value. | Medium4 | SimulationArray | No attempts yet | 1s | 128 MB | Judgeable |
| Box SortingSort an array into increasing order using the minimum number of cyclic-rotation commands, following a specified cycle-decomposition construction. | Medium4 | ArraySimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| A Library at HomeFind the minimum number of top-moves needed so a pile of numbered books ends up sorted 1..N from top to bottom. | Medium4 | GreedyArray | No attempts yet | 1s | 128 MB | Judgeable |
| Graphics QuizFor each of 5 grades, find the longest contiguous run of desks where at least one student has that grade, then output the best length and the smallest grade achieving it. | Medium4 | ArraySliding window+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Seat WarGiven a grid of people and seats, count seats where two or more people are tied at the minimum distance to that seat. | Medium4 | ArrayBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Next Greater Number with the Same DigitsGiven an integer, find the smallest number larger than it using exactly the same multiset of digits, or print 0 if impossible. | Medium4 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Choosing a NameGiven even integers and a range [A,B], find an odd integer in that range maximizing the minimum distance to all given even values. | Medium4 | ArrayGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| FireflyGiven alternating stalagmite and stalactite lengths in a cave, find the flight height destroying the fewest obstacles and how many heights tie for that minimum. | Medium4 | Prefix sumArray | No attempts yet | 1s | 128 MB | Judgeable |
| AntsSimulate two colliding groups of ants swapping adjacent opposite-direction ants each second and output the arrangement after T seconds. | Medium4 | SimulationArray | No attempts yet | 1s | 128 MB | Judgeable |
| Bridging SignalsGiven a permutation of wire connections between two ports, find the longest increasing subsequence to maximize non-crossing signals. | Medium4 | Binary searchDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Battle Order ScoreCount pairs of items whose relative order matches between a reference sequence and a given permutation, and print as a fraction over N(N-1)/2. | Medium4 | ArrayBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Good FriendsCount pairs of students within rank distance K whose names have equal length, given names in rank order. | Medium4 | Sliding windowArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Candy GameGiven a colored N×N grid, determine the longest same-color run achievable in any row or column after performing exactly one swap of two adjacent different-colored cells. | Medium4 | SimulationBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Teams with Sum ZeroCount the number of index triples among N students whose skill values sum to exactly zero. | Medium4 | ArrayTwo pointers+1 | No attempts yet | 4s | 128 MB | Judgeable |
| Kkung the ShepherdUsing grid flood-fill to find fenced regions, determine for each region whether sheep or wolves survive by comparing counts, then output totals. | Medium4 | BFSArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| MOSimulate an alternating stone-placing game on a 1D board where placing a stone can capture an enclosed run of opponent stones, then count remaining stones of each color. | Medium4 | SimulationArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Who Wins Gold, Silver, and Bronze?Given each athlete's live rank as they finish two sequential races, reconstruct final standings from the second race and output the top three athlete numbers. | Medium4 | SimulationArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| SpiesSimulate a walk on a grid and report which given spy coordinates ever fall within Chebyshev distance 1 of the walker's path. | Medium4 | SimulationArray | No attempts yet | 1s | 128 MB | Judgeable |
| SearchTrack all reachable cells on a grid as a car moves in given directions by at least one free cell each step, then mark final possible positions. | Medium4 | SimulationArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Multi-key SortingGiven a sequence of stable column sorts, output the shortest equivalent sequence by keeping only the last occurrence of each column value in the order that determines the final effect. | Medium4 | ArrayGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| The RiddleFind the minimum prefix length of a coin sequence so that all values from 1 to K are achievable as subset sums, using the classic greedy reachable-range extension, or report -1. | Medium4 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Reducing a SequenceGiven a sequence, find the minimum total cost of repeatedly merging adjacent elements where cost equals the max of the pair, until one element remains. | Medium4 | GreedyArray | No attempts yet | 1s | 128 MB | Judgeable |
| Robot ProjectGiven a target length and up to a million rod lengths, find two rods summing exactly to the target with the maximum length difference, or report impossibility. | Medium4 | Two pointersSorting+1 | No attempts yet | 5s | 256 MB | Judgeable |
| Movie CollectionGiven a stack of DVDs and a sequence of watched movie numbers, output for each watch how many DVDs sat above it before moving it to the top. | Medium4 | ArraySimulation+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Divisible Contiguous SubarraysCount contiguous subarrays whose sum is divisible by a given d, using prefix sums modulo d and counting equal remainders. | Medium4 | Prefix sumHash map+1 | No attempts yet | 1s | 128 MB | Judgeable |
| TableGiven an N by M table, compute each column's product and output the column index (largest index on tie) with the maximum product, handling big products across up to 1000 rows. | Medium4 | MathSimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Rising TrendFor each test case, compute the length of the longest strictly increasing subsequence in a sequence of up to 100000 prices. | Medium4 | Dynamic programmingBinary search+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Republic of KoreaCount crossing pairs among K straight highways linking numbered east and west coast cities, using inversion counting. | Medium4 | SortingDivide and conquer+1 | No attempts yet | 1s | 128 MB | Judgeable |
| TourGiven points sorted by x-coordinate, compute the shortest bitonic tour that goes strictly left-to-right then strictly right-to-left, using classic O(n^2) DP. | Medium4 | Dynamic programmingGeometry+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Condorcet ParadoxGiven b ranked ballots over c candidates, find the candidate who beats every other candidate head to head on more than half the ballots. | Medium4 | ArraySimulation+2 | No attempts yet | 5s | 128 MB | Judgeable |
| CDGiven two sorted lists of distinct CD numbers, count how many numbers appear in both lists. | Medium4 | Two pointersSorting+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Unique SnowflakesGiven a stream of integer snowflake ids, find the length of the longest contiguous block in which every value is distinct. | Medium4 | Sliding windowHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Dragon of LoowaterMatch the smallest knight to each dragon head so that every head is cut by a tall enough knight, minimizing total height paid; report failure if impossible. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| InterpreterSimulate a 10-register, 1000-word RAM machine that executes encoded 3-digit instructions, and count how many instructions run before the halt. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Australian VotingSimulate multi-round preferential voting: eliminate the lowest candidates each round and transfer their ballots until someone exceeds 50% or a tie remains. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Let the Wookiee Win!On a 5x5 board, find the single empty square where playing O neither makes four O in a row nor blocks any of X's winning squares. | Medium4 | ImplementationBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Wandering AimlesslySimulate NPC movement scripts on a grid, converting blocked steps into pauses, looping or reversing scripts, and print the map after T turns. | Medium4 | SimulationImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Tribute (Editor)Simulate a buggy modal editor: given keystrokes, apply insert, delete, duplicate, reverse, and cursor commands, then print the buffer with a caret marking the cursor position. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Artificial StrifeSimulate multiple Game of Life rule sets on one grid for T turns, resolving collisions alphabetically, and report each species' maximum and minimum population. | Medium4 | SimulationArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| JugglefestSimulate the first 20 throws of a siteswap pattern, assigning balls in order of first use, and detect any time two balls are due on the same throw. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Pascal's TravelsCount paths on an n by n digit board from top-left to bottom-right, where each square's digit sets the exact right or down step length. | Medium4 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ColorvilleSimulate players advancing on a colored board by drawing cards, and report who wins or that the deck ran out. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Instruens FabulamRead a header specifying each column's alignment, then print each table with borders, sized columns, and aligned cells. | Medium4 | StringImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MapmakerGiven array declarations with bounds and element sizes, compute each reference's physical address with the row-major address formula. | Medium4 | ArrayMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Portfolio RebalancingSimulate each term's fixed fee, percentage fee, and return per instrument, pool and redistribute every NREBALANCE terms, and print each ending balance to two decimals. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Wooden BlocksGiven a string of digit pieces, check whether it forms a valid interlocking arrangement starting with piece 1, ending with piece 2, and matching every adjacent edge pair. | Medium4 | ImplementationString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Still Johnny Can't AddDecide whether an N by N grid can be written as row label plus column label for all cells, up to N=10. | Medium4 | ArrayMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Pablo Squarson's HeadacheGiven how N unit squares are attached one by one to an existing square in one of four directions, compute the width and height of the resulting figure. | Medium4 | SimulationArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Exotic FoodsGiven a sequence of food values, choose a subset with no two chosen positions adjacent so the total value is as large as possible. | Medium4 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| EcosystemGiven populations and per-member diets for species ordered by food chain position, simulate feeding in increasing species order and report survivors. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RotateReverse a sequence of operations: first undo a rotation of each block of K, then undo a rotation of the whole sequence, recovering the original array. | Medium4 | ImplementationSimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Shut the Box IGiven a target sum and a sorted list of open card values, choose the subset summing to the target that is lexicographically largest when sorted. | Medium4 | BacktrackingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Coin CollectionA robot walks right or down only from the top-left to the bottom-right of a grid, and we want the most coins it can pick up along the way. | Medium4 | Dynamic programmingMatrix+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Next PermutationGiven an integer A, find the smallest permutation of its digits that is strictly greater than A, or print USELESS if none exists. | Medium4 | ArrayString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ACApply a string of reverse (R) and discard-first (D) operations to an integer array, printing the result or error if D hits an empty array. | Medium4 | ImplementationArray+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Planet ExplorationGiven a grid of jungle, sea, and ice cells, answer many rectangle queries by counting how many cells of each terrain type fall inside. | Medium4 | Prefix sumArray+2 | No attempts yet | 1s | 256 MB | Judgeable |
| PizzaGiven store positions on a circular road and delivery points, sum the distance from each point to its nearest store. | Medium4 | Binary searchArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Tornado!Given a circular fence of N posts marked standing or broken, choose the fewest broken posts to fill so no wire span between standing posts exceeds 4 meters. | Medium4 | GreedyArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BrothersGiven a grid of counties owned by heirs in a cycle, apply K simultaneous rounds where a cell switches to the previous heir if an orthogonal neighbor already has that heir, then print the grid. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Where Are My GenesApply a sequence of reversals to the identity genome and report the final position of each queried gene. | Medium4 | SimulationArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| DiceSimulate a board game where players advance by dice totals, skip a turn when landing on one of three traps, and the first past the last square wins. | Medium4 | SimulationImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow CrossingsCount cows whose straight crossing paths intersect no other cow, where two paths cross exactly when the start and end left-to-right orders differ. | Medium4 | SortingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Meet and GreetSimulate two cows walking along a line at unit speed and count how many times they meet after being apart, excluding the start. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| iPhone 9SRemove everyone in the line who wants one chosen capacity, then report the longest run of equal capacities that remains. Choose the capacity to maximize that run. | Medium4 | ArrayImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Rope FoldingGiven knots at integer positions on a rope, count the fold points where every knot in the overlapping interval mirrors onto another knot. | Medium4 | ArrayBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Haybale StackingAdd one bale to every stack in each given range, then report the median height among all N stacks. | Medium4 | Prefix sumArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Moo SickFind every window of C consecutive notes whose sorted, min-subtracted shape matches the given chord's shape. | Medium4 | ArraySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |