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,802 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Arranging Go StonesStones are added one by one; each even-indexed stone of a new color replaces the trailing run of the opposite color, and we count the white stones that remain. | Medium5 | StackSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sum of a SequenceGiven an N by N table holding Ai+Aj for every pair of distinct indices and 0 on the diagonal, recover the original positive sequence A. | Medium5 | MathArray+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Good NumbersCount the elements A_i that equal the sum of three elements appearing earlier in the sequence, where the same earlier element may be reused. | Medium5 | Hash mapBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Klingon Course LevelsPick a score threshold T that splits every division into basic and advanced groups, minimizing the sum over divisions of |basic - advanced|. Output that minimum. | Medium5 | SortingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Pole PositionGiven the current race order of N cars with each car's position change from the start, reconstruct the starting grid or report that no valid grid exists. | Medium5 | ArraySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bora BoraSimulate a children's card game with turn order, direction changes, forced draws and skips, and a fixed discard rule, and report the winner. | Medium5 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SupermarketGiven a shopping list and products in path order, buy the list items in order from later positions at minimum total cost, or report impossible. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BookshelfPartition the books in order into shelves whose widths sum to at most L, minimizing the total of each shelf's maximum height. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| IslandsGiven heights along a line, find the maximum number of separate exposed segments at any single rising water level. | Medium5 | SortingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow LineGiven N up to 20, convert between a permutation of 1..N and its lexicographic rank among all permutations, for up to 10000 queries. | Medium5 | CombinatoricsMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Rubik's CubeSimulate Rubik's Cube face turns from an unfolded starting state and print the final facelet colors in the same layout. | Medium5 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Switching LightsMaintain a binary array of N lights under M range-toggle and range-count operations, and print each query result. | Medium5 | Segment treeArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Hay For SaleGiven a wagon capacity and a list of hay bale volumes, find the largest total volume not exceeding the capacity that can be formed by choosing whole bales. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Patting HeadsEach of N cows has a value; for every cow count how many other cows hold a value that divides hers. | Medium5 | MathNumber theory+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sand CastleGiven current merlon heights and a multiset of target heights in any order, pair them to minimize the total cost of raising and lowering, where raising costs X and lowering costs Y. | Medium5 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow CashCount the number of unordered ways to make an amount N using V coin denominations, where each coin can be used any number of times. | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Privileged CowsGiven a sequence of 1s, 2s, and 3s, find the minimum number of arbitrary swaps needed to group all 1s first, then all 2s, then all 3s. | Medium5 | GreedyArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Charm BraceletChoose a subset of N charms, each with a weight and a desirability, so that total weight stays within M and total desirability is maximized. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Balanced LineupGiven a static array of cow heights, answer queries giving the max minus min over each range [A, B]. | Medium5 | Segment treeArray | No attempts yet | 1s | 128 MB | Judgeable |
| Managing AllowanceFind the smallest fixed withdrawal amount K so that the N daily costs can be covered using exactly M withdrawals, counting forced top-ups and optional extra ones. | Medium5 | Binary searchGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Chessboard DanceSimulate a beetle on an 8x8 board following move and turn commands, pushing chains of pieces that may fall off the board. | Medium5 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| El DoradoCount the increasing subsequences of length exactly k in a sequence of n distinct numbers, for several test cases. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| God Save the i-th QueenGiven a board and placed queens, count empty squares not sharing a row, column, or diagonal with any queen. | Medium5 | ArrayHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Railway TransportationSplit the arrival sequence into the fewest contiguous-order groups, each nondescending in arrival order, and report the count or failure if it exceeds M. | Medium5 | GreedyBinary search+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Sea BattleCount rectangular ships of '#' cells on a grid, verify no two touch even diagonally, and report bad placement if the ships are not valid rectangles. | Medium5 | ImplementationArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Pinball RankingGiven scores in play order, compute each game's rank as one plus the number of earlier-or-later scores strictly above it, then output the average rank as a reduced fraction. | Medium5 | Binary searchSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MõttemeisterGiven several guesses and their correct-digit counts A and position counts B, list every 4-digit secret number consistent with all clues. | Medium5 | Brute forceImplementation+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Sawtooth SequenceGiven N distinct numbers, arrange all of them into a zigzag sequence and output the lexicographically smallest such arrangement. | Medium5 | GreedySorting+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Repeated Permutation CipherGiven a permutation key and a repeat count k, apply the permutation to each padded message k times and print the result. | Medium5 | ArrayImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Card Game CheaterEve knows Adam's card order and must permute her own cards to maximize the number of positions where her card beats his. | Medium5 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| False CoinGiven recorded balance weighings of N coins with exactly one false coin, output the coin number if the results identify it uniquely, otherwise 0. | Medium5 | Brute forceImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bin PackingPack items into identical bins holding at most two items each so that the number of bins is minimized. | Medium5 | GreedyTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Catching FishGiven up to 100 fish on a large grid and a fixed net perimeter, find the placement of the net that covers the most fish. | Medium5 | Brute forcePrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| FactoryGiven two orderings of the same N numbers, count pairs of connecting cables that cross when drawn as straight lines. | Medium5 | SortingPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Arm Wrestling TournamentSimulate a single-elimination arm wrestling bracket of 2^N players where winners lose strength and recover K before each match; report the champion and the opponents beaten. | Medium5 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Random GapGiven a linear congruential generator, find the largest gap between neighboring distinct values the sequence produces. | Medium5 | SimulationHash map+2 | No attempts yet | 4s | 128 MB | Judgeable |
| SkyscrapersFor each queried day, count maximal blocks of adjacent skyscrapers whose heights exceed the rising sea level. | Medium5 | SortingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| SortingCount the swaps made by a given selection-style double loop on an array. | Medium5 | SortingArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| IslandGiven the edge lengths of a cycle, find the maximum over all pairs of towns of the shorter of the two arc distances. | Medium5 | Two pointersPrefix sum+1 | No attempts yet | 3s | 512 MB | Judgeable |
| InsulatorGiven n positive coefficients, reorder them so that the sum plus the total of positive rises between adjacent layers is as large as possible, and print that maximum. | Medium5 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| OrienteeringGiven the cyclic sequence of stage difficulties around a loop, decide whether some starting point and direction make the difficulties non-increasing. | Medium5 | ArrayGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| MapCount the marked points that have at least one point strictly below-left, above-right, below-right, and above-left of them. | Medium5 | SortingArray | No attempts yet | 1s | 128 MB | Judgeable |
| Apples and Apple TreesGiven positions of n trees and m apples on a line, find the minimum distance from any apple to its nearest tree. | Medium5 | SortingBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| EncyclopediaGiven a stack of n pages and n sleeves, swap adjacent elements to make the two types alternate, and output the minimum number of swaps. | Medium5 | GreedyArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Viewing TerracesIn a chain of terraces where climbing up costs height difference and descending is free, find the most distinct terraces reachable on k credits without returning to ground. | Medium5 | Sliding windowTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ButtonsSimulate single counter increments and global max-fill operations to find the final counter values. | Medium5 | SimulationArray | No attempts yet | 1s | 512 MB | Judgeable |
| Car WorkshopsCars pass through workshops in order and each one repaints color a to b on a match, so compute every final color. | Medium5 | SimulationArray | No attempts yet | 1s | 512 MB | Judgeable |
| DistanceChoose two array elements, possibly the same element twice, to maximize the sum of the two values plus the distance between their positions. | Medium5 | GreedyArray | No attempts yet | 1s | 128 MB | Judgeable |
| CitiesCount for each city on a directed line how many other cities are reachable through one-way and two-way roads. | Medium5 | ArrayPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| ChildrenGiven a permutation on n cells, find the fewest adjacent swaps so every walk visits all cells. | Medium5 | GraphArray | No attempts yet | 1s | 128 MB | Judgeable |
| WatchtowersFind the maximum sum over any nonempty block of consecutive towers arranged in a circle. | Medium5 | Dynamic programmingArray | No attempts yet | 1s | 128 MB | Judgeable |
| More Garden TroublesFind the fewest flamethrower shots that clear every plot when each shot halves a plot and its two neighbors, rounding down. | Medium5 | GreedyMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Math NotebookChoose a contiguous block from both sequences to maximize its dot product with the reversed second block. | Medium5 | Brute forceArray | No attempts yet | 1s | 128 MB | Judgeable |
| Canoe AthletesPick one weight from each of four lists so the total is closest to the target, preferring the smaller total on ties. | Medium5 | Binary searchSorting+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Mod-3 PermutationCount entries by index and value residues mod 3, fix directly swappable pairs first, then resolve each leftover triple with two swaps. | Medium5 | GreedyMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Global WarmingGiven column heights, find the greatest number of maximal above-water runs over all real sea levels. | Medium5 | Union-findSorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| BaumkuchenSplit the circular cake into three contiguous pieces so the smallest piece is as large as possible. | Medium5 | Binary searchTwo pointers+1 | No attempts yet | 2s | 256 MB | Judgeable |
| VacationFrom a start city on a line with a fixed day budget where each move or city visit costs one day, pick the contiguous block with the most attractions. | Medium5 | Two pointersPrefix sum+1 | No attempts yet | 5s | 64 MB | Judgeable |
| Fuleco and the AntGiven positions A and B and a U/D string encoding depth changes along a tree walk, output the tree distance between the two forks. | Medium5 | TreePrefix sum+1 | No attempts yet | 1s | 64 MB | Judgeable |
| Salad BarFind the longest contiguous block of apples and oranges where oranges never fall behind apples when added from either end. | Medium5 | Prefix sumStack+1 | No attempts yet | 3s | 256 MB | Judgeable |
| EquatorEach test case gives city profits around a circle and asks for the most profitable contiguous block, or zero when all are losses. | Medium5 | Dynamic programmingArray | No attempts yet | 1s | 256 MB | Judgeable |
| Cow JogCount the groups of cows that end at the same position after T minutes when no cow can pass the cow ahead. | Medium5 | GreedyArray | No attempts yet | 1s | 256 MB | Judgeable |
| Honey Butter ChipArrange the M extra bags within the N fixed bags and pick no two adjacent bags to maximize the chip total. | Medium5 | Dynamic programmingArray | No attempts yet | 5s | 256 MB | Judgeable |
| Maximize DifferencesReorder the given array so the sum of absolute differences between neighbors is as large as possible. | Medium5 | GreedySorting+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Counting Cafeteria MenusCount how many distinct dish sets appear when the current set of N out of M dishes shifts forward by one each meal. | Medium5 | String matchingArray+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Car GameFind the first dictionary word that contains each three-letter plate as a subsequence, or report that none exists. | Medium5 | String matchingArray | No attempts yet | 2s | 256 MB | Judgeable |
| Maximal AreaGiven N column heights, find the area of the largest rectangle formed by whole unit squares. | Medium5 | StackArray | No attempts yet | 2s | 256 MB | Judgeable |
| Cube IV (Large)Find the longest run of consecutive room numbers placed in neighboring cells and report its starting number and length. | Medium5 | Dynamic programmingGraph+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Theme Park (Large)Groups board a coaster holding at most k people in queue order and rejoin the back after riding, and R runs of earnings must be totaled. | Medium5 | SimulationQueue+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Picking Up ChicksCount the fewest adjacent swaps so at least K chicks, slowed by slower chicks ahead, reach the barn by time T. | Medium5 | GreedyArray | No attempts yet | 5s | 512 MB | Judgeable |
| Crazy Rows (Small)Given an N by N binary matrix, reorder the rows using adjacent swaps so each row's rightmost 1 is at or left of its position, minimizing swaps. | Medium5 | GreedySorting+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Saving the Universe (Large)Given a query stream and a set of engines, choose which engine handles each query, never an engine matching the query, to minimize the number of switches. | Medium5 | GreedyImplementation+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Legendary JBNUMaintain a set of integer keys with values, supporting insert, update-by-nearest-key, and query that prints the nearest key's value, -1, or ?. | Medium5 | ArraySorting+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Roller CoasterFrom a sequence of column heights, delete columns so the survivors strictly decrease then strictly increase (either part may be empty); output the maximum number of survivors. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SouvenirParticipants sit in a circle; stage t removes the t^3-th person counting clockwise from the current host, and you find the last survivor. | Medium5 | SimulationQueue+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Intervals of Unique NumbersCount pairs (i, j) where the subarray from i to j has all distinct values, with N up to 100000. | Medium5 | Two pointersSliding window+2 | No attempts yet | 1s | 32 MB | Judgeable |
| Minimum SwapsGiven permutations A and B, find the minimum number of swaps within A that turn it into B. | Medium5 | ArrayHash map+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Secret PasswordGiven two length-N sequences, decide whether one is a cyclic rotation of the other. | Medium5 | String matchingArray+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Gas StationsGiven road lengths and per-city fuel prices on a line, buy fuel along the way to minimize the total cost of driving from the first city to the last. | Medium5 | GreedyArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Water PumpPlace one pump in a cell, let water drain toward it from both sides, and find the cell that removes the most water. | Medium5 | ArrayPrefix sum | No attempts yet | 2s | 512 MB | Judgeable |
| Contiguous Sum 2Find the maximum contiguous subarray sum after optionally deleting at most one element from the sequence. | Medium5 | Dynamic programmingArray | No attempts yet | 2s | 512 MB | Judgeable |
| Rouba-MonteSimulate a card game where players draw, steal montes, and discard mismatches; report the winners by monte size. | Medium5 | SimulationImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Isosceles Cube TriangleGiven column heights, find the largest h such that some 2h-1 consecutive columns can all be reduced to the shape 1,2,...,h,...,2,1. | Medium5 | ArrayBrute force+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Command HistoryGiven a sequence of positions in a command history, simulate running each command by the nearest occurrence and total the up-arrow presses needed. | Medium5 | ArrayHash map+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Stock exchangeGiven daily prices and a fixed fee per buy, find the maximum total profit when holding at most one share at a time and each share must be sold later. | Medium5 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Strange BarGiven N kettle volumes and K people, find the largest integer amount X such that the sum over all kettles of floor(volume / X) is at least K. | Medium5 | Binary searchArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Making the Array PalindromicMerge adjacent elements (each merge sums them) so the resulting array reads the same forwards and backwards, using the fewest merges. All values are positive. | Medium5 | Two pointersGreedy+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Project PanoptesGiven n brightness readings and a lower bound p, find the smallest k >= p such that some arithmetic progression with step k lands only on dim days, where dim means below 0.8 times the average; output -1 if none exists. | Medium5 | ArrayBrute force+2 | No attempts yet | 2s | 512 MB | Judgeable |
| RobotGiven a grid with obstacles, a start cell, and a fixed cycling order of the four directions, simulate the robot that moves straight until blocked and report where it stops. | Medium5 | SimulationImplementation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Key KnockingGiven a binary string of length 3n, greedily pick operations in each 3-bit block to reach a weight of at least 2n within n moves. | Medium5 | GreedyImplementation+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Weird Measurements (Medium)Count the contiguous subarrays whose consecutive differences alternate in sign, with no zero differences allowed. | Medium5 | ArrayTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Large Weird MeasurementsCount all contiguous intervals whose consecutive differences strictly alternate in sign, with any length-1 interval counting as weird. | Medium5 | ArrayTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Broadcast TowerPlace a tower of height H in a row of buildings; a building west of it receives its signal if no taller building blocks the path. Maximize receivers. | Medium5 | StackArray | No attempts yet | 2s | 512 MB | Judgeable |
| Reading ListTotal lifted books over a sequence of assignments, where each assigned book moves to the top of the tower. | Medium5 | ArraySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ĆevapiEach day a new raft joins; simulate Goran's run across both banks under L meters and report meters on each bank and the portions eaten. | Medium5 | SimulationSorting+1 | No attempts yet | 3s | 128 MB | Judgeable |
| SnakeSimulate snakes that move forward, or turn right then left, given a board with obstacles for T seconds. | Medium5 | SimulationImplementation+1 | No attempts yet | 4s | 64 MB | Judgeable |
| Banknotes and RouletteSplit banknotes so the two equal-sum groups leave the smallest leftover, then add half of twice that leftover to each person's total. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Score of a SubsequenceFind the maximum over all contiguous subarrays of the weighted sum where the k-th element from the subarray start contributes k times its value. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Company Culture 2Given a tree of boss relations, apply subtree-wide praise additions in real time and answer point total queries. | Medium5 | TreeDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| TetrominoGiven an N x M grid of positive integers, place one of the 5 tetrominoes (with rotations and reflections) to maximize the sum of covered cells. | Medium5 | Brute forceImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |