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 |
|---|---|---|---|---|---|---|
| AI Tetris (Small)Given a 20x10 Tetris board, find the maximum number of rows a single dropped piece can clear, assuming it falls straight down. | Medium5 | SimulationImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Scallion ChickenFind the largest integer piece length x such that the scallions yield at least C pieces, then print the total leftover length. | Medium5 | Binary searchGreedy+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Archers of the Geumgang RangeEach archer's dragon moves right and eats peaks lower than its start until it meets a taller peak; find the largest count any archer can eat. | Medium5 | StackArray+2 | No attempts yet | 2s | 256 MB | Judgeable |
| RainwaterGiven stack heights across a 2D world, compute the total rainwater trapped between the blocks after heavy rain. | Medium5 | ArrayTwo pointers+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Circular HighwayCount starting stations on a circular road where buying all fuel and driving forward never empties the tank before returning. | Medium5 | Prefix sumGreedy+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Hamming distance queriesGiven binary strings a and b, answer queries asking for the Hamming distance between a substring of a and a substring of b. | Medium5 | Prefix sumString+2 | No attempts yet | 6s | 512 MB | Judgeable |
| RampsCount rows or columns where every cell has equal height, or where unit ramps of length L can bridge each height step of exactly 1. | Medium5 | ImplementationSimulation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Mixing two solutionsGiven a sorted array of N integers, choose two different elements whose sum is closest to 0, breaking ties toward the smaller (negative) sum. | Medium5 | Two pointersSorting+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Building a ranchGiven an M by N grid with trees and rocks as obstacles, find the side length of the largest square subgrid that contains no obstacle. | Medium5 | Dynamic programmingMatrix+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Flea MarketEach person has a supply or demand of fleas at unit-distance positions; find the minimum total delivery cost. | Medium5 | GreedyPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Escaping the BarracksFind the minimum level needed to walk from (0,0) to (n-1,m-1) on an n by m grid, using at most one jump that skips over exactly one block in a straight line. | Medium5 | Binary searchBFS+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Deranging HatGiven a string, find a sorting network that turns its sorted letters back into the original string, following a specified rule. | Medium5 | SimulationSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| EducationAssign departments to buildings by a deterministic greedy rule after sorting students descending, matching each to the cheapest available building that fits. | Medium5 | GreedySorting+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Foosball DynastySimulate a foosball variation where seats rotate after each point and report the team whose scoring streak lasted longest. | Medium5 | SimulationImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Purple RainGiven a string of R and B characters, find the contiguous block maximizing |r - b|, breaking ties by westernmost start then westernmost end. | Medium5 | ArrayGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Greedy GenerositySimulate a vending machine's coin stock over several purchases, adding a greedy overpayment when exact greedy change is impossible, and report the total excess paid. | Medium5 | SimulationGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Candy SalesFor each day j, print the minimum over all i at most j of w_i + (j - i). | Medium5 | ArrayPrefix sum+1 | No attempts yet | 6s | 512 MB | Judgeable |
| Killer SudokuRead a 19 by 37 ASCII diagram of a Killer Sudoku grid plus one sum per cage, and report OK or NotOK for all constraints. | Medium5 | ImplementationSimulation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| DebugEach call increments every index divisible by the given jump; answer range-sum queries over the resulting array. | Medium5 | ArrayMath+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Easy QuestGiven a sequence of gifts (+type), costs (-type), and unicorns (0), decide if every cost can be paid and choose the lexicographically smallest item type for each unicorn. | Medium5 | GreedyImplementation+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Cakey McCakeFaceGiven sorted entry and exit timestamps, find the smallest nonnegative time difference d that maximizes how many entry times t satisfy t + d is an exit time. | Medium5 | Hash mapArray+2 | No attempts yet | 7s | 512 MB | Judgeable |
| Hangul LCSGiven two Hangul strings of up to 1000 characters each, compute the length of their longest common subsequence in characters. | Medium5 | Dynamic programmingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Consultations before resignationGiven up to 1.5 million days, each with a job of length T_i and pay P_i, pick jobs that fit before day N+1 to maximize total pay. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Pascal's triangleBuild Pascal's triangle and sum all entries inside the equilateral sub-triangle whose top cell is row R, position C, with side length W. | Medium5 | ArrayDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Maximum range sum? 1Maintain an array under point updates. For each range query, find the maximum of U times a subarray sum plus V times its length over all subarrays inside the range. | Medium5 | ArrayBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cute RyanGiven a row of N dolls labeled 1 or 2, find the length of the shortest contiguous block containing at least K dolls labeled 1. | Medium5 | Two pointersSliding window+2 | No attempts yet | 1s | 256 MB | Judgeable |
| The LawyerFor each day, decide whether two of that day's meetings are disjoint and, if so, output the pair with the smallest earlier-meeting index, then smallest later index. | Medium5 | SortingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Gears (2)Simulate K turns on a row of 8-tooth gears where a turning gear rotates its neighbor only if the touching teeth have opposite poles, then count gears whose top tooth is S. | Medium5 | SimulationImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Cowburger set discountGiven prices for burgers, sides, and drinks, report the undiscounted total and the minimum total after forming disjoint triples where each item in a set is sold at 10% off. | Medium5 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Zigzag SequenceGiven a sequence, find the longest contiguous block in which no three consecutive terms are monotone increasing or monotone decreasing. | Medium5 | ArrayTwo pointers+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Counting the closest pair sumsGiven n integers and a target v, count how many index pairs have a sum whose distance from v is as small as possible. | Medium5 | SortingTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Balloon FactoryFind the minimum time for N workers, each producing one balloon every A_i minutes, to finish M balloons in parallel. | Medium5 | Binary searchGreedy+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Drain PipesCount the number of ways to pick quantities of each pipe type, within the given stock, so the chosen pipes sum to exactly x. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Ah-Choo!Compute the least Dynamic Time Warping distance between two equal-length integer sequences, where every point must match at least one point of the other and matches cannot cross. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Martian DNAGiven a string over K symbols and minimum counts for R of them, find the length of the shortest contiguous substring meeting all the quotas, or report impossible. | Medium5 | Sliding windowArray+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| Rotating SushiOn a circular belt of N sushi plates, find the maximum number of distinct kinds in any k consecutive plates, counting the coupon kind c once more if it is not already present. | Medium5 | Sliding windowTwo pointers+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Longest Consecutive SubsequenceGiven an integer sequence, find the longest subsequence whose values form an arithmetic run with common difference 1, keeping the original order. | Medium5 | Dynamic programmingHash map+1 | No attempts yet | 2s | 256 MB | Judgeable |
| EvakumMaintain an array with range-add updates and range-sum queries, answering the queries in the order given. | Medium5 | Prefix sumArray+2 | No attempts yet | 1.5s | 256 MB | Judgeable |
| Meditation DisturberEach bird on the left or right chirps on some seconds; remove one bird so the peak absolute value of the running signed sum over M seconds is minimized, and report its index and that value. | Medium5 | Prefix sumImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Missing GnomesGiven a subsequence of 1..n, find the lexicographically smallest permutation of 1..n that contains it as a subsequence. | Medium5 | GreedyImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| SignalDecode a 5-row pixel strip into digits: 3-column glyphs except 1, separated by blank columns. | Medium5 | ImplementationArray+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Non-Violent ProtestsGiven each person's threshold, find how many riot if someone riots once that many others already do. | Medium5 | GreedySorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Longest Increasing Palindromic SubsequenceGiven up to 10^5 integers, find the longest contiguous subarray that is a palindrome whose values strictly rise from both ends toward the center. | Medium5 | StringTwo pointers+1 | No attempts yet | 1.5s | 512 MB | Judgeable |
| Jumping King Jelly (Small)Given an N by N board with jump numbers, move only right or down from the top-left and reach the bottom-right, or report failure. | Medium5 | DFSBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| DSHS BankPick the branch minimizing the total taxicab distance to all others, breaking ties by smallest branch number. | Medium5 | MathSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| A Prize No One Can WinPick a largest subset of item prices such that no pair has a sum strictly greater than X, and print its size. | Medium5 | ArraySorting+2 | No attempts yet | 1.5s | 512 MB | Judgeable |
| FishermenCount for each fisherman how many fish satisfy |x - a| + y <= l, given fish and fishermen positions on a line. | Medium5 | ArraySorting+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Sharing the SnacksGiven M children and N snack sticks, find the maximum integer length where cutting gives every child one equal piece, or 0 if impossible. | Medium5 | Binary searchGreedy+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Area RugCount dirty cells under an s-by-s rug at every placement on an n-by-n grid, then report how many placements cover each possible count. | Medium5 | Prefix sumArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Chicken Chicken ChickenGiven N members' preference scores for M chicken kinds, choose at most 3 kinds to maximize the sum over members of their highest preference among the chosen kinds. | Medium5 | Brute forceImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Small PenaltyPick one card from each of three players so the max minus min of the chosen numbers is as small as possible, and report that range. | Medium5 | SortingTwo pointers+1 | No attempts yet | 1s | 512 MB | Judgeable |
| AchievementsGiven practice days and a budget of paid days, find the longest run of consecutive days where the number of skipped days does not exceed the budget. | Medium5 | Two pointersArray+1 | No attempts yet | 1s | 512 MB | Judgeable |
| KleptographyRecover an autokey ciphertext's plaintext when only its last n letters are known, using the known tail to decrypt backwards through the keystream. | Medium5 | ArrayImplementation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Guest StudentGiven a weekly class schedule and k, find the shortest consecutive span of days covering exactly k class days. | Medium5 | ArraySimulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| TeamworkPartition cows in a row into blocks of at most K so each block contributes its maximum times block size; maximize the sum. | Medium5 | Dynamic programmingArray | No attempts yet | 2s | 512 MB | Judgeable |
| Japan SinksRaise the sea level through the section heights and track how maximal runs of above-level sections merge; report the largest island count seen. | Medium5 | SortingUnion-find+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Where is the BoundaryGiven m binary strings of length n, cut the line between two prefectures and label each side east or west to minimize mismatches. Report the two prefectures meeting at the best cut, choosing the westernmost one on ties. | Medium5 | Prefix sumArray+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Array Rotation 1Rotate each concentric ring of an N by M matrix counterclockwise R times, then print the resulting matrix. | Medium5 | MatrixSimulation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Rotating an Array 2Rotate each concentric layer of an N by M matrix one cell counterclockwise, R times, and print the final matrix. | Medium5 | MatrixSimulation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Rotating an Array 3Apply a sequence of up to 1000 operations (vertical flip, horizontal flip, quarter rotations, and quadrant swaps) to an N by M array and print the final arrangement. | Medium5 | ImplementationSimulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Value of Array BSwap at most one pair of rows or columns in an N by M grid to maximize the sum of all 2 by 2 block sums. | Medium5 | ArrayGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sleepy Cow SortingGiven a permutation of 1..N, repeatedly move the front cow any number of paces back; find the minimum number of steps to reach sorted order. | Medium5 | GreedyArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Placing Two CrossesGiven a small grid of '.' and '#', place two non-overlapping crosses made of '#' cells and maximize the product of their areas. | Medium5 | Brute forceImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Subsequence with the Largest Maximum-Minimum DifferenceGiven a sequence, find the shortest contiguous segment whose max minus min equals the largest such difference over all segments. | Medium5 | Two pointersArray+2 | No attempts yet | 0.5s | 256 MB | Judgeable |
| OperationsMaintain a sparse integer array under point add, point reset, and range sum queries, printing the whole-array sum after each update. | Medium5 | Segment treePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Gahui's Remainder Sequence Game (Small)Maintain a sequence under push and pop from the back, and for each type-3 query report the shortest suffix whose values cover every residue 0 to mod-1, or -1 if impossible. | Medium5 | StackArray+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Bowling Score CalculationGiven a string describing each ball's result in a 10-frame bowling game (S for strike, P for spare, - for zero, digits otherwise), compute the final score using strike and spare bonus rules. | Medium5 | SimulationImplementation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Largest Sum Decreasing SubsequenceGiven a sequence, find a strictly decreasing subsequence with the maximum possible sum and print that sum. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Strength ContestFor each split of a line of fighters into a left and right team, the max of each side fights; count which side wins more splits, or report a tie. | Medium5 | Prefix sumArray+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Dark TunnelStreetlights sit at fixed positions along a tunnel from 0 to N, each lighting H units left and right; find the smallest integer H that covers the whole road. | Medium5 | Binary searchGreedy+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Next Greater ElementFor each element of a sequence, output the nearest greater value to its right, or -1 if none exists. | Medium5 | StackArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Frequency-Greater Next ElementFor each position, find the nearest value to its right whose total frequency in the array exceeds the frequency of the current element, or -1 if none exists. | Medium5 | StackHash map+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Stars Falling from the Sky: 1, 2, ..., R-L+1 of ThemMaintain an array where a range update adds 1,2,...,R-L+1 to positions L..R, and point queries ask the current total at one index. | Medium5 | Prefix sumArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| FLEXDistribute M extra ten-thousand-won units among N days to minimize the sum of squared drops between consecutive daily spends. | Medium5 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Brazilian Popcorn MarathonSplit a row of popcorn bags into at most C contiguous segments, minimizing the maximum segment sum given each competitor eats at most T per second. | Medium5 | Binary searchGreedy+2 | No attempts yet | 1.5s | 512 MB | Judgeable |
| Find my FamilyFor each photo, decide whether some arrangement lets Alice (taller than you) stand left of you and Bob (taller than both) stand right of you. | Medium5 | ArrayPrefix sum+2 | No attempts yet | 7s | 512 MB | Judgeable |
| Screamers in the StormSimulate T turns of wolves and sheep moving, eating, and starving on a small grid, and print the final tile states. | Medium5 | SimulationImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Snail ListA linked list has a tail node N pointing back to node V, forming one cycle. For each query K, report the value stored in the node reached after moving K steps from node 1. | Medium5 | Linked listArray+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Course SelectionChoose courses with given importance and study time so total time stays within N and total importance is maximized. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Musical ChairsSimulate the Josephus elimination where each eliminated person's own number k sets the next count length, and print the last survivor. | Medium5 | SimulationQueue+2 | No attempts yet | 1s | 512 MB | Judgeable |
| FishmongersAssign each fish to a fishmonger with a weight limit and per-kilogram price so total earnings are maximized. | Medium5 | GreedySorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Keyboards in ConcertGiven n keyboards, the sets of notes each can play, and the note sequence of a tune, find the minimum number of keyboard switches needed to play the whole tune. | Medium5 | Dynamic programmingHash map+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Fire on FieldDefine a sequence where each term is the smallest positive integer that avoids forming an arithmetic progression with any earlier pair at equal spacing, and print the n-th term. | Medium5 | Brute forceImplementation+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Balanced AnimalsFind the smallest integer threshold t that splits the animals by weight into two groups of equal total weight, handling ties at t by pairing them off. | Medium5 | SortingPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Managing DifficultiesCount triples of increasing indices i < j < k where a[j] - a[i] equals a[k] - a[j], so a[i] + a[k] = 2*a[j]. | Medium5 | Hash mapCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Inverted DeckGiven a sequence, find one contiguous segment whose reversal makes the whole sequence non-decreasing, or report that no such segment exists. | Medium5 | ArrayGreedy+2 | No attempts yet | 5s | 512 MB | Judgeable |
| SpeedingGiven positions and times of a car at checkpoints, find the largest integer speed the car must have reached at some moment. | Medium5 | GreedyMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Buying Ramen (Small)Buy exactly Ai packs from each factory using 1-pack, 2-pack, or 3-pack deals with different costs, minimizing total money. | Medium5 | GreedyDynamic programming+2 | No attempts yet | 0.5s | 32 MB | Judgeable |
| Multiverse ITwo universes are equal when their size arrays induce the same ordering and tie pattern. Replace each array by its rank pattern and count equal pairs. | Medium5 | SortingHash map+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Social Distancing IIGiven cow positions on a line and which cows are sick, find the smallest number of cows that could have been infected at the start, given an unknown infection radius R. | Medium5 | SortingGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| ElectionsChoose the fewest polling stations to cancel so that candidate n's total votes are not strictly greater than every other candidate's total. | Medium5 | GreedySorting+2 | No attempts yet | 3s | 512 MB | Judgeable |
| A Really Odd SequenceGiven a sequence of integers, find the maximum sum of a contiguous subarray whose length is odd. | Medium5 | ArrayDynamic programming+2 | No attempts yet | 6s | 512 MB | Judgeable |
| Apple TreeGiven N target heights, decide whether a 1-unit and a 2-unit watering can, used simultaneously on trees (or together on one tree), can reach exactly those heights. | Medium5 | GreedyMath+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| MountainsCount triples x < y < z where the middle mountain y is strictly taller than both mountain x and mountain z. | Medium5 | ArrayCombinatorics+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Nonconsecutive SortRearrange up to 50 integers into the lexicographically smallest sequence where no value is immediately followed by the value one greater than it. | Medium6 | GreedySorting+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Card ShufflingGiven a permutation of card positions and a target assignment of each card to a player, find the minimum number of shuffles so every card reaches its target player, or -1. | Medium6 | ArrayMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Height ArrangementArrange N heights around a circular table so the maximum difference between adjacent people is minimized, breaking ties by lexicographically smallest order. | Medium6 | SortingGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| NMKConstruct a permutation of 1..N whose longest increasing subsequence is exactly M and longest decreasing subsequence is exactly K, or report impossible. | Medium6 | CombinatoricsGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Subsequence Sum Count 2Count the number of non-empty subsequences of up to 40 integers whose sum equals a given target S using a meet-in-the-middle approach. | Medium6 | Brute forceBinary search+2 | No attempts yet | 1s | 256 MB | Judgeable |
| String DistanceGiven strings O and N, find the minimum number of substring-insertion operations to turn O into N, or output -1 if impossible. | Medium6 | Dynamic programmingString+2 | No attempts yet | 2s | 128 MB | Judgeable |