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 |
|---|---|---|---|---|---|---|
| Dividing the LootGiven N item values and P other pirates, choose a set of items for yourself so no other pirate gets more items than you, maximizing your total value. | Medium6 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| King Jaguar's PyramidPlace an a by b pyramid and an interior c by d chamber on a grid to maximize the sum of base squares minus chamber squares. | Medium6 | Prefix sumBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Drawing with XOREach XOR call flips a rectangle anchored at the bottom right, so the number of calls equals the count of pixels that differ from the pixel below and the pixel to the right, plus the bottom-right pixel. | Medium6 | ArrayMatrix+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Light Bulb DecorationGiven a binary string, flip at most one contiguous range so that some contiguous alternating substring becomes as long as possible, and report that length. | Medium6 | ArrayPrefix sum+2 | 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 |
| 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 |
| BacteriaSimulate K bacteria moving on a grid, each turning by a digit read from its own matrix, and report when all share the trap cell. | Medium6 | SimulationImplementation+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 |
| Grandpa's Rubik CubeGiven a Rubik's cube configuration and a list of face rotations, decide whether applying them all yields a solved cube with each face a single color. | Medium6 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| CrossNumberFill a digit-grid puzzle where each across and down run must match a given digit sum, always leaving a word with one blank cell to solve. | Medium6 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Farm PaintingGiven up to 50,000 non-intersecting axis-aligned rectangles, count how many are not contained inside any other rectangle. | Medium6 | SortingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow LineupGiven a sequence of N breed IDs, remove at most K distinct breed IDs so that the longest run of equal IDs in the remaining sequence is maximized. | Medium6 | Sliding windowTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Painting the FenceBessie walks along a number line and each segment she covers gains a coat of paint; find the total length covered by at least K coats. | Medium6 | IntervalsSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Above the MedianGiven N cow heights, count contiguous ranges whose defined median (the ceil(K/2)-th smallest) is at least a threshold X. | Medium6 | Prefix sumBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Treasure ChestTwo players alternately take a coin from either end of a row of N coins; find the maximum total the first player can guarantee with optimal play. | Medium6 | Dynamic programmingGame theory+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Trick or Treat on the FarmEach stall has one outgoing next pointer. For every starting stall, count how many distinct stalls the walk visits before it first revisits a stall. | Medium6 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Super PaintballGiven up to 100000 opponent positions on an N by N grid, count cells from which a shot along its row, column, or either diagonal would pass through every opponent. | Medium6 | Brute forceImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| River CrossingSplit N cows into consecutive groups, each crossing costs M plus the cumulative marginal cost, and add M for every return trip; minimize the total time. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Big SquarePlace one extra 'J' on an empty cell of an N by N grid so that the four corners of some 'J' square have the largest possible area. | Medium6 | GeometryBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow Roller CoasterChoose components that tile [0, L] with no gaps or overlaps, maximizing total fun while keeping total cost within budget B. | Medium6 | Dynamic programmingSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Standing Long JumpRemove exactly m of n interior stones so the smallest gap between consecutive stepping points from 0 to d is as large as possible. | Medium6 | Binary searchGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Balanced LineupGiven N cow heights and Q ranges, report the difference between the maximum and minimum height within each query range. | Medium6 | Segment treeArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cheapest PalindromeGiven a string and per-letter insertion and deletion costs, find the minimum cost to turn it into a palindrome by adding or removing characters anywhere. | Medium6 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Leaking DikeGiven building heights in a row, water pours over a dike on the left at 1 square meter per minute; find how long until a given building's roof sits 1 meter under water. | Medium6 | ArraySimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TrianglesIn each triangular grid of white and black cells, find the area of the largest all-white triangle, which may point up or down. | Medium6 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| HeartsSimulate a simplified Hearts game with fixed strategies and report the heart points won by each of the five players, starting with the dealer. | Medium6 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Shuffling PatienceSimulate a solitaire game that covers complementary pairs or JQK triples across up to 16 piles, and report the final pile sizes or the overflow card number. | Medium6 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PostScript Printer DriverSimulate a page renderer that places font C1 and 5x6 asterisk-font C5 strings on a 60x60 grid with left, right, center, and absolute justification, where blanks and dots never overwrite. | Medium6 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Largest Rectangle in a HistogramGiven a histogram of unit-width bars with varying heights, find the area of the largest rectangle that fits inside it, processing several test cases until a 0 terminates input. | Medium6 | StackArray+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Parallel Computer SimulatorSimulate up to ten concurrent programs on one CPU with FIFO scheduling, quantum preemption, and lock/unlock mutual exclusion, then report prints in execution order. | Medium6 | SimulationQueue+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Returning BooksTrack which books are on the shelves and which sit at the desk, then on each SHELVE command report where each returned book belongs by comparing author and title in ASCII order. | Medium6 | SortingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Computer Purchase ReturnChoose exactly one component of each of T types so the total cost stays within budget B and the total value is maximized. | Medium6 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| CowsGiven up to 10000 tree coordinates, find the largest convex polygon using any subset as corners, then output its area divided by 50 rounded down. | Medium6 | GeometrySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Stepping on TilesGiven N distinct increasing numbers, find the maximum sum of a 3-or-more element arithmetic subsequence with any common difference, or 0 if none exists. | Medium6 | Dynamic programmingHash map+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Stacking CubesGiven a stacking pattern as non-increasing rows with non-increasing columns, print its left and right rotations as corner stackings. | Medium6 | ArrayImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TicketsSplit L pages of non-increasing popularity into D contiguous channel blocks to minimize the popularity-weighted sum of within-block delay positions, breaking ties by the lexicographically smallest block boundaries. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Õhne vanaraamatupoodSimulate bots that repeatedly recompute their book price from the previous day's average, and print every bot's price on the morning of day T. | Medium6 | ImplementationSimulation+2 | No attempts yet | 1s | 1023 MB | Judgeable |
| Flipping a Pack of CardsSimulate a deck of n cards under m prefix-reversal-and-flip operations, then report the final position and face direction of s queried cards. | Medium6 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| DragonPick two disjoint blocks of at most K consecutive heads each in a row of N heads to maximize the total fire power removed. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Buffet TableOn a circle of N trays, a walker repeatedly jumps K steps clockwise, collecting each visited tray once until it revisits a tray; find the start that maximizes the total. | Medium6 | Number theoryMath+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| The Cat of BitlandTwo rows of K (friendly) and A (allergic) students; the cat moves right in a row or jumps to any later room in the other row, and we want the most rooms it can visit. | Medium6 | Dynamic programmingArray+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Swimming CompetitionSplit a sorted list of N swimmer times into consecutive heats of size A to B, minimizing the largest within-heat gap between fastest and slowest. | Medium6 | Binary searchGreedy+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Square IceGiven an alternating sign matrix, render the corresponding square ice grid using H, O, dashes, bars, and an asterisk border. | Medium6 | ImplementationMatrix+2 | No attempts yet | 1s | 128 MB | Judgeable |
| DefragmentGiven files spread over N disk clusters, find the minimum number of single-cluster moves to place them contiguously in order, with file i starting after file i-1. | Medium6 | GreedyArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Four Integers Summing to ZeroCount the number of index tuples (a, b, c, d) with A[a] + B[b] + C[c] + D[d] = 0, given four arrays of size n. | Medium6 | Hash mapSorting+2 | No attempts yet | 12s | 1024 MB | Judgeable |
| CitystarFor each street, find the five house numbers whose span (max minus min plus 1) is smallest, breaking ties by the smallest house numbers. | Medium6 | SortingSliding window+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Castle WallsGiven blue and red hooks with distinct line positions, count blue-red pairs whose endpoints satisfy the crossing inequality. | Medium6 | SortingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Lining Up in OrderGiven a permutation of 1..N, find the fewest children to move to either end so the line becomes increasing; the answer is N minus the longest run of consecutive values that already appears in increasing order. | Medium6 | ArrayDynamic programming+1 | No attempts yet | 1s | 256 MB | Judgeable |
| ProbeGiven range-sum probe results on a length-K binary road, find the lexicographically smallest object placement satisfying all of them, or NONE. | Medium6 | ArrayPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| AppChoose a subset of active apps to deactivate whose freed memory is at least M while minimizing the total deactivation cost. | Medium6 | Dynamic programmingArray | No attempts yet | 1s | 128 MB | Judgeable |
| Cell phone tunesDecide whether a given tune is good (no adjacent equal-multiset blocks), contains all n sounds, and cannot be extended by a single sound on either end. | Medium6 | String matchingImplementation+1 | No attempts yet | 1s | 32 MB | Judgeable |
| Pizza Delivery ScheduleGiven recorded pizza deliveries by week and weekday, find the fixed weekly-cycle schedule of period 1 to 4 weeks that minimizes mismatched days. | Medium6 | Brute forceImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TerrariumSimulate up to 26 snakes crawling one cell per second on an N x N grid for T seconds and print the final board. | Medium6 | SimulationImplementation+1 | No attempts yet | 3s | 128 MB | Judgeable |
| The DragonPick an order of pastures from either end each day, losing a sheep per day everywhere, to maximize total sheep eaten. | Medium6 | GreedySorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Cheap TravelsPick a sequence of hotels so consecutive stops are at most 800 km apart, minimizing total price (ties: fewest nights), and also minimizing nights (ties: lowest price). | Medium6 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Two CakesTwo cakes must be built layer by layer from two given permutations, using one dedicated worker per layer type; find the minimum total time. | Medium6 | GreedyArray+2 | No attempts yet | 4s | 128 MB | Judgeable |
| RooksComplete a partially filled n by n board to a full non-attacking rook placement, choosing the lexicographically smallest completion. | Medium6 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| KangaroosFor each lens interval, find the longest contiguous block of sighting intervals that all overlap it. | Medium6 | IntervalsSorting+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Speed LimitsGiven speed limits on intervals of a highway plus a car's top speed, pick the single limit whose removal maximizes total satisfaction (distance times speed). | Medium6 | ArrayPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| NumberEaterCount the number of distinct value sets obtainable as the set of a contiguous subarray of the given sequence. | Medium6 | Hash mapArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Longest Common Increasing SubsequenceFind the length of the longest strictly increasing sequence that is a subsequence of both given sequences. | Medium6 | Dynamic programmingArray | No attempts yet | 1s | 128 MB | Judgeable |
| AlgebraDecide whether a target permutation can be reached from the identity using only rotations of three distinct positions. | Medium6 | MathArray | No attempts yet | 1s | 128 MB | Judgeable |
| Genome EvolutionCount the shared gene blocks of length above one that appear as consecutive runs in both chromosomes. | Medium6 | IntervalsArray | No attempts yet | 1s | 128 MB | Judgeable |
| CirclelandYou start at room R1 on a corridor cycle and visit every room, then leave through any exit while walking the shortest total corridor distance. | Medium6 | GreedyPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Kabaleo LitePick a stack for your last chip so your hidden colour stays the strictly most visible colour whatever rivals play, and list every stack with that guarantee. | Medium6 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Longest Arithmetic ProgressionFind the length of the longest subsequence of the given sorted list that forms an arithmetic progression. | Medium6 | Dynamic programmingArray | No attempts yet | 2s | 1024 MB | Judgeable |
| Mascot SongMaintain an array under point updates and left rotations, reporting the number of maximal strictly increasing runs after each query. | Medium6 | ArraySimulation | No attempts yet | 1s | 32 MB | Judgeable |
| EraserGiven a sequence, add the products of every triple of entries at distinct positions with three different values, modulo 1,000,000,007. | Medium6 | CombinatoricsMath+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Parcel PostsSplit the elevation array into the most contiguous parcels so each parcel contains a triple whose middle value is strictly above or below both outer values. | Medium6 | GreedyArray | No attempts yet | 20s | 1024 MB | Judgeable |
| Mine Layer (Small)Given a small Minesweeper-style clue grid (R is 3 or 5, C is 3 to 5), find the maximum number of mines the middle row can hold over all layouts that match the clues. | Medium6 | Brute forceBacktracking+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Pat PatAfter point swaps in an array, answer queries asking whether a subarray is nondecreasing. | Medium6 | Segment treeArray | No attempts yet | 1s | 256 MB | Judgeable |
| Colorful VillageMaintain N houses under range repaint operations and answer queries counting how many of the T colors appear in a range. | Medium6 | Segment treeBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Delete the X-th smallest numberMaintain a multiset under insertions and queries that report and delete the X-th smallest element, with values and query count up to 2e6. | Medium6 | Segment treeBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Number LockGiven two equal-length digit strings S and T, find the minimum number of turns where each turn adds 1 or subtracts 1 (mod 10) to every dial in some contiguous range. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Time Travel and MultisetProcess insert, delete, and count operations on a time-indexed multiset, where each value's count at time t depends on prior operations with time at most t. | Medium6 | Dynamic programmingBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Colorful Village 2For each query range in a nondecreasing brightness array, report how many times the most frequent value appears. | Medium6 | ArrayBinary search+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Shifting a MatrixParse a compressed shift-operation string with nested repetitions, apply the row and column rotations to an N by N matrix, and print the result. | Medium6 | SimulationImplementation+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Maximum Clique of an Interval GraphGiven N intervals, find a largest set of pairwise overlapping intervals, and output its size plus the vertex indices in lexicographically smallest order. | Medium6 | SortingGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Happy KindergartenSplit a non-decreasing array of heights into K contiguous groups to minimize the sum of each group's max-minus-min. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Cocktail Shaker SortSimulate cocktail shaker sort on a permutation and report the number of swaps performed in each of the N steps. | Medium6 | ArraySimulation+1 | No attempts yet | 1s | 512 MB | Judgeable |
| JetpackFind the lexicographically smallest schedule of screen holds that moves Barry right across N columns through a 10-row grid while avoiding obstacles. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 64 MB | Judgeable |
| CardsGiven an even row of cards with integers, two players alternately take an end card; the first player maximizes his total sum while the second minimizes it. Report the best score the first player can guarantee. | Medium6 | Dynamic programmingGame theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Parking LotSimulate a single-line parking lot where each arriving vehicle takes the first free gap from the entrance that fits, and total the fees for vehicles that park. | Medium6 | SimulationImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Musical PlagiarismGiven a song as a sequence of notes and a suspect excerpt, decide whether the excerpt appears in the song under some transposition (key change). | Medium6 | String matchingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Earl's Extremely Efficient EncryptionGiven a growing set of stored image indices, find the longest run of consecutive unmarked indices below each query length w_j. | Medium6 | ArraySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Flipping SwitchesSimulate the given local-search procedure: repeatedly flip the lowest-numbered switch that increases the number of shining lights, then print the final setting. | Medium6 | SimulationGreedy+2 | No attempts yet | 7s | 512 MB | Judgeable |
| Step Step EvolutionGiven a sequence of dance-pad arrows, find the minimum number of adjacent pairs pressed by the same foot, respecting the left/right column rule. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 8s | 512 MB | Judgeable |
| CommuteGiven a grid of vertical/horizontal blocks and a fixed set of moves, find the fewest steps from any vertical block in row 0 to row R-1. | Medium6 | BFSGraph+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Suspicious SamplesFor each condition, count samples whose value is greater or less than the min, max, or average of samples in the preceding time window. | Medium6 | Sliding windowQueue+2 | No attempts yet | 2s | 512 MB | Judgeable |
| PohlepkoFind the lexicographically smallest string read along a monotone path from the top-left to the bottom-right cell of a grid of lowercase letters. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 64 MB | Judgeable |
| RAMProcess files one by one; after each, count how many times a given letter appears in the last K characters seen so far. | Medium6 | ArraySimulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Big TableEach row of a huge table repeats a short digit period; answer rectangle-sum queries without materializing the table. | Medium6 | Prefix sumMath+2 | No attempts yet | 4s | 128 MB | Judgeable |
| ArchitectGiven N tree points and Q axis-aligned polygons of at most 12 vertices, count for each polygon how many trees lie inside it, border included. | Medium6 | GeometryArray+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Array CharacteristicMove one element to any position and maximize the weighted sum of A_i times its new index. | Medium6 | ArrayPrefix sum | No attempts yet | 2s | 512 MB | Judgeable |
| Fortune telling with sticksGiven an n by m letter grid and p query words, find for each word the longest contiguous substring that can be placed along a row or column in one of four directions. | Medium6 | Brute forceImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Foehn PhenomenaAfter each range add to altitudes, report the wind temperature at spot N, where the total depends on the altitude differences between adjacent spots. | Medium6 | ArrayPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Sequence and Queries 16Maintain an array under point updates and range queries that ask for the leftmost index of the minimum value in a subarray. | Medium6 | Segment treeArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 17Maintain an array under point updates and answer range-minimum queries over subarrays. | Medium6 | Segment treeArray+2 | No attempts yet | 2s | 512 MB | Judgeable |