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
TitleLevelTopicsSolvedTime limitMemory limitJudge
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.Medium5SimulationImplementation+2No attempts yet1s512 MBJudgeable
Scallion ChickenFind the largest integer piece length x such that the scallions yield at least C pieces, then print the total leftover length.Medium5Binary searchGreedy+2No attempts yet2s256 MBJudgeable
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.Medium5StackArray+2No attempts yet2s256 MBJudgeable
RainwaterGiven stack heights across a 2D world, compute the total rainwater trapped between the blocks after heavy rain.Medium5ArrayTwo pointers+2No attempts yet1s256 MBJudgeable
Circular HighwayCount starting stations on a circular road where buying all fuel and driving forward never empties the tank before returning.Medium5Prefix sumGreedy+1No attempts yet1s512 MBJudgeable
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.Medium5Prefix sumString+2No attempts yet6s512 MBJudgeable
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.Medium5ImplementationSimulation+1No attempts yet2s512 MBJudgeable
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.Medium5Two pointersSorting+1No attempts yet1s512 MBJudgeable
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.Medium5Dynamic programmingMatrix+2No attempts yet1s512 MBJudgeable
Flea MarketEach person has a supply or demand of fleas at unit-distance positions; find the minimum total delivery cost.Medium5GreedyPrefix sum+1No attempts yet1s128 MBJudgeable
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.Medium5Binary searchBFS+2No attempts yet1s256 MBJudgeable
Deranging HatGiven a string, find a sorting network that turns its sorted letters back into the original string, following a specified rule.Medium5SimulationSorting+2No attempts yet2s512 MBJudgeable
EducationAssign departments to buildings by a deterministic greedy rule after sorting students descending, matching each to the cheapest available building that fits.Medium5GreedySorting+2No attempts yet5s512 MBJudgeable
Foosball DynastySimulate a foosball variation where seats rotate after each point and report the team whose scoring streak lasted longest.Medium5SimulationImplementation+2No attempts yet2s512 MBJudgeable
Purple RainGiven a string of R and B characters, find the contiguous block maximizing |r - b|, breaking ties by westernmost start then westernmost end.Medium5ArrayGreedy+2No attempts yet1s512 MBJudgeable
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.Medium5SimulationGreedy+2No attempts yet2s512 MBJudgeable
Candy SalesFor each day j, print the minimum over all i at most j of w_i + (j - i).Medium5ArrayPrefix sum+1No attempts yet6s512 MBJudgeable
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.Medium5ImplementationSimulation+2No attempts yet1s512 MBJudgeable
DebugEach call increments every index divisible by the given jump; answer range-sum queries over the resulting array.Medium5ArrayMath+2No attempts yet3s512 MBJudgeable
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.Medium5GreedyImplementation+2No attempts yet3s512 MBJudgeable
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.Medium5Hash mapArray+2No attempts yet7s512 MBJudgeable
Hangul LCSGiven two Hangul strings of up to 1000 characters each, compute the length of their longest common subsequence in characters.Medium5Dynamic programmingString+2No attempts yet2s512 MBJudgeable
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.Medium5Dynamic programmingArray+2No attempts yet2s512 MBJudgeable
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.Medium5ArrayDynamic programming+2No attempts yet1s512 MBJudgeable
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.Medium5ArrayBrute force+2No attempts yet1s128 MBJudgeable
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.Medium5Two pointersSliding window+2No attempts yet1s256 MBJudgeable
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.Medium5SortingGreedy+2No attempts yet2s512 MBJudgeable
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.Medium5SimulationImplementation+2No attempts yet2s512 MBJudgeable
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.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
Zigzag SequenceGiven a sequence, find the longest contiguous block in which no three consecutive terms are monotone increasing or monotone decreasing.Medium5ArrayTwo pointers+2No attempts yet1s1024 MBJudgeable
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.Medium5SortingTwo pointers+2No attempts yet2s512 MBJudgeable
Balloon FactoryFind the minimum time for N workers, each producing one balloon every A_i minutes, to finish M balloons in parallel.Medium5Binary searchGreedy+2No attempts yet1s256 MBJudgeable
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.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
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.Medium5Dynamic programmingArray+1No attempts yet1s512 MBJudgeable
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.Medium5Sliding windowArray+2No attempts yet2s1024 MBJudgeable
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.Medium5Sliding windowTwo pointers+2No attempts yet1s512 MBJudgeable
Longest Consecutive SubsequenceGiven an integer sequence, find the longest subsequence whose values form an arithmetic run with common difference 1, keeping the original order.Medium5Dynamic programmingHash map+1No attempts yet2s256 MBJudgeable
EvakumMaintain an array with range-add updates and range-sum queries, answering the queries in the order given.Medium5Prefix sumArray+2No attempts yet1.5s256 MBJudgeable
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.Medium5Prefix sumImplementation+2No attempts yet2s512 MBJudgeable
Missing GnomesGiven a subsequence of 1..n, find the lexicographically smallest permutation of 1..n that contains it as a subsequence.Medium5GreedyImplementation+2No attempts yet2s512 MBJudgeable
SignalDecode a 5-row pixel strip into digits: 3-column glyphs except 1, separated by blank columns.Medium5ImplementationArray+1No attempts yet1s512 MBJudgeable
Non-Violent ProtestsGiven each person's threshold, find how many riot if someone riots once that many others already do.Medium5GreedySorting+1No attempts yet2s512 MBJudgeable
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.Medium5StringTwo pointers+1No attempts yet1.5s512 MBJudgeable
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.Medium5DFSBacktracking+2No attempts yet1s128 MBJudgeable
DSHS BankPick the branch minimizing the total taxicab distance to all others, breaking ties by smallest branch number.Medium5MathSorting+2No attempts yet2s512 MBJudgeable
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.Medium5ArraySorting+2No attempts yet1.5s512 MBJudgeable
FishermenCount for each fisherman how many fish satisfy |x - a| + y <= l, given fish and fishermen positions on a line.Medium5ArraySorting+1No attempts yet1s512 MBJudgeable
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.Medium5Binary searchGreedy+1No attempts yet1s256 MBJudgeable
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.Medium5Prefix sumArray+2No attempts yet2s512 MBJudgeable
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.Medium5Brute forceImplementation+1No attempts yet1s128 MBJudgeable
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.Medium5SortingTwo pointers+1No attempts yet1s512 MBJudgeable
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.Medium5Two pointersArray+1No attempts yet1s512 MBJudgeable
KleptographyRecover an autokey ciphertext's plaintext when only its last n letters are known, using the known tail to decrypt backwards through the keystream.Medium5ArrayImplementation+1No attempts yet2s512 MBJudgeable
Guest StudentGiven a weekly class schedule and k, find the shortest consecutive span of days covering exactly k class days.Medium5ArraySimulation+2No attempts yet2s512 MBJudgeable
TeamworkPartition cows in a row into blocks of at most K so each block contributes its maximum times block size; maximize the sum.Medium5Dynamic programmingArrayNo attempts yet2s512 MBJudgeable
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.Medium5SortingUnion-find+2No attempts yet2s512 MBJudgeable
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.Medium5Prefix sumArray+2No attempts yet5s512 MBJudgeable
Array Rotation 1Rotate each concentric ring of an N by M matrix counterclockwise R times, then print the resulting matrix.Medium5MatrixSimulation+2No attempts yet1s512 MBJudgeable
Rotating an Array 2Rotate each concentric layer of an N by M matrix one cell counterclockwise, R times, and print the final matrix.Medium5MatrixSimulation+2No attempts yet1s512 MBJudgeable
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.Medium5ImplementationSimulation+2No attempts yet2s512 MBJudgeable
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.Medium5ArrayGreedy+2No attempts yet2s512 MBJudgeable
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.Medium5GreedyArray+2No attempts yet2s512 MBJudgeable
Placing Two CrossesGiven a small grid of '.' and '#', place two non-overlapping crosses made of '#' cells and maximize the product of their areas.Medium5Brute forceImplementation+2No attempts yet2s512 MBJudgeable
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.Medium5Two pointersArray+2No attempts yet0.5s256 MBJudgeable
OperationsMaintain a sparse integer array under point add, point reset, and range sum queries, printing the whole-array sum after each update.Medium5Segment treePrefix sum+2No attempts yet2s512 MBJudgeable
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.Medium5StackArray+1No attempts yet1s256 MBJudgeable
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.Medium5SimulationImplementation+2No attempts yet1s256 MBJudgeable
Largest Sum Decreasing SubsequenceGiven a sequence, find a strictly decreasing subsequence with the maximum possible sum and print that sum.Medium5Dynamic programmingArray+2No attempts yet1s256 MBJudgeable
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.Medium5Prefix sumArray+2No attempts yet1s256 MBJudgeable
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.Medium5Binary searchGreedy+2No attempts yet1s256 MBJudgeable
Next Greater ElementFor each element of a sequence, output the nearest greater value to its right, or -1 if none exists.Medium5StackArray+2No attempts yet1s512 MBJudgeable
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.Medium5StackHash map+2No attempts yet1s512 MBJudgeable
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.Medium5Prefix sumArray+2No attempts yet1s512 MBJudgeable
FLEXDistribute M extra ten-thousand-won units among N days to minimize the sum of squared drops between consecutive daily spends.Medium5Dynamic programmingGreedy+2No attempts yet2s512 MBJudgeable
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.Medium5Binary searchGreedy+2No attempts yet1.5s512 MBJudgeable
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.Medium5ArrayPrefix sum+2No attempts yet7s512 MBJudgeable
Screamers in the StormSimulate T turns of wolves and sheep moving, eating, and starving on a small grid, and print the final tile states.Medium5SimulationImplementation+2No attempts yet2s512 MBJudgeable
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.Medium5Linked listArray+2No attempts yet1s256 MBJudgeable
Course SelectionChoose courses with given importance and study time so total time stays within N and total importance is maximized.Medium5Dynamic programmingArray+2No attempts yet1s512 MBJudgeable
Musical ChairsSimulate the Josephus elimination where each eliminated person's own number k sets the next count length, and print the last survivor.Medium5SimulationQueue+2No attempts yet1s512 MBJudgeable
FishmongersAssign each fish to a fishmonger with a weight limit and per-kilogram price so total earnings are maximized.Medium5GreedySorting+2No attempts yet1s512 MBJudgeable
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.Medium5Dynamic programmingHash map+2No attempts yet1s512 MBJudgeable
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.Medium5Brute forceImplementation+1No attempts yet1s512 MBJudgeable
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.Medium5SortingPrefix sum+2No attempts yet1s512 MBJudgeable
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].Medium5Hash mapCombinatorics+2No attempts yet2s512 MBJudgeable
Inverted DeckGiven a sequence, find one contiguous segment whose reversal makes the whole sequence non-decreasing, or report that no such segment exists.Medium5ArrayGreedy+2No attempts yet5s512 MBJudgeable
SpeedingGiven positions and times of a car at checkpoints, find the largest integer speed the car must have reached at some moment.Medium5GreedyMath+2No attempts yet1s512 MBJudgeable
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.Medium5GreedyDynamic programming+2No attempts yet0.5s32 MBJudgeable
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.Medium5SortingHash map+2No attempts yet1s512 MBJudgeable
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.Medium5SortingGreedy+2No attempts yet1s512 MBJudgeable
ElectionsChoose the fewest polling stations to cancel so that candidate n's total votes are not strictly greater than every other candidate's total.Medium5GreedySorting+2No attempts yet3s512 MBJudgeable
A Really Odd SequenceGiven a sequence of integers, find the maximum sum of a contiguous subarray whose length is odd.Medium5ArrayDynamic programming+2No attempts yet6s512 MBJudgeable
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.Medium5GreedyMath+2No attempts yet1s1024 MBJudgeable
MountainsCount triples x < y < z where the middle mountain y is strictly taller than both mountain x and mountain z.Medium5ArrayCombinatorics+2No attempts yet2s256 MBJudgeable
Nonconsecutive SortRearrange up to 50 integers into the lexicographically smallest sequence where no value is immediately followed by the value one greater than it.Medium6GreedySorting+2No attempts yet2s128 MBJudgeable
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.Medium6ArrayMath+2No attempts yet2s128 MBJudgeable
Height ArrangementArrange N heights around a circular table so the maximum difference between adjacent people is minimized, breaking ties by lexicographically smallest order.Medium6SortingGreedy+2No attempts yet2s128 MBJudgeable
NMKConstruct a permutation of 1..N whose longest increasing subsequence is exactly M and longest decreasing subsequence is exactly K, or report impossible.Medium6CombinatoricsGreedy+2No attempts yet2s128 MBJudgeable
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.Medium6Brute forceBinary search+2No attempts yet1s256 MBJudgeable
String DistanceGiven strings O and N, find the minimum number of substring-insertion operations to turn O into N, or output -1 if impossible.Medium6Dynamic programmingString+2No attempts yet2s128 MBJudgeable