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 results2,743 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Jumping Across LogsArrange the given log heights in a circle to minimize the largest height gap between neighbors.Medium5GreedySortingNo attempts yet1s256 MBJudgeable
PokerCompare two five-card poker hands by standard rankings and kicker tiebreakers and print the winning hand or Tie.Medium5ImplementationSortingNo attempts yet1s256 MBJudgeable
SurfPick waves with no wait-time overlap so the sum of fun points is as large as possible.Medium5Dynamic programmingSorting+1No attempts yet4s256 MBJudgeable
Workstation assignmentSeat each arriving researcher at a freed workstation that stayed unlocked to save the most unlocks.Medium5GreedyHeap+1No attempts yet10s256 MBJudgeable
Perica's PianoSort the N key values and add each value multiplied by the number of K-sets where it is the largest, modulo 1000000007.Medium5CombinatoricsSorting+1No attempts yet1s64 MBJudgeable
Preserving the GridPlace d partitions between cells of a 1 by n board holding k horses to maximize cells no horse can reach.Medium5GreedySortingNo attempts yet1s32 MBJudgeable
Load BalancingPlace one vertical and one horizontal fence between the odd-coordinate cow positions to minimize the largest cow count in any of the four regions.Medium5SortingPrefix sum+1No attempts yet2s512 MBJudgeable
Load BalancingJohn places one vertical and one horizontal fence to minimize the largest cow count in the four regions.Medium5Brute forceSortingNo attempts yet1s512 MBJudgeable
Diamond CollectorSort the diamond sizes and pick two disjoint groups with spread at most K to maximize the total count.Medium5SortingTwo pointersNo attempts yet2s512 MBJudgeable
Mr. Kim's Grocery Store (Small)Given the sorted pile of 2N mixed normal and discounted price tags, recover the N sale prices.Medium5GreedyHash map+1No attempts yet5s512 MBJudgeable
Kim Incheon's Grocery Store (Large)Given 2N sorted tags that pair N sale prices with regular prices at 4/3 of each sale price, recover the N sale tags.Medium5GreedyHash map+1No attempts yet5s512 MBJudgeable
Lunch MenuCount the menus whose spiciness falls in [u, v] and whose sweetness falls in [x, y] for each query.Medium5Segment treeSorting+1No attempts yet1s512 MBJudgeable
TournamentWith free seeding of 2^N numbers in a knockout bracket, find the best level each number can reach.Medium5SortingMathNo attempts yet3s64 MBJudgeable
Fairland (Small)Marie keeps the largest manager-closed team containing herself whose salaries span at most D.Medium5TreeDFS+2No attempts yet5s512 MBJudgeable
Up and Down SequenceCount the fewest adjacent swaps that turn distinct numbers into a sequence that rises to one peak and then falls.Medium5Brute forceSortingNo attempts yet5s512 MBJudgeable
The RepeaterEqualize N lowercase strings using only adjacent duplicate insertions and deletions with the fewest moves, or report impossibility.Medium5StringSorting+1No attempts yet5s512 MBJudgeable
The Repeater (Large)Decide whether N lowercase strings can be made identical by duplicating or deleting adjacent equal letters, and report the fewest moves.Medium5StringSorting+1No attempts yet5s512 MBJudgeable
Rural PlanningArrange every post into a simple polygon larger than half the convex hull area by building the two specified hull-chain orders and keeping the larger one.Medium5GeometrySorting+1No attempts yet5s512 MBJudgeable
The Great Wall (Small)Count the interval attacks that breach a wall which rises to each successful attack's strength, judging attacks on the same day against the unchanged wall.Medium5SimulationIntervals+1No attempts yet5s512 MBJudgeable
Osmos (Small)Starting from size A, sort the other motes and absorb each smaller one, adding helper motes or deleting blockers for the fewest operations.Medium5GreedySortingNo attempts yet5s512 MBJudgeable
Osmos (Large)Starting from size A, absorb the sorted motes in order and use the fewest added or removed motes to clear each blocker.Medium5GreedySortingNo attempts yet5s512 MBJudgeable
Safety in NumbersCompute for each contestant the smallest vote percentage that guarantees another contestant ties or trails them no matter how the remaining votes split.Medium5MathBinary search+1No attempts yet5s512 MBJudgeable
Equal SumsGiven up to 20 distinct numbers, print the two lexicographically smallest distinct subsets that share the smallest repeated sum, or Impossible.Medium5Brute forceHash map+1No attempts yet20s512 MBJudgeable
Kingdom RushEarn one-star and two-star clears with star thresholds in an order that finishes every level with two stars in the fewest plays.Medium5GreedySortingNo attempts yet5s512 MBJudgeable
Kingdom Rush (Large)Find the fewest level completions that earn a 2-star rating on every level when each level needs minimum star counts for its 1-star and 2-star plays.Medium5GreedySortingNo attempts yet5s512 MBJudgeable
Best coffee (Small)Pick one coffee cup per day from kinds with limited cups and expiry days to maximize total satisfaction over K days.Medium5GreedySortingNo attempts yet5s512 MBJudgeable
Morning Coffee (Large)Choose one cup per day from day 1 to K so no kind is drunk past its deadline and total satisfaction is largest.Medium5GreedyHeap+1No attempts yet5s512 MBJudgeable
Dire Straights (Small)Split the hand into groups of consecutive values to make the shortest group as long as possible.Medium5BacktrackingSortingNo attempts yet5s512 MBJudgeable
Airport Walkways (Small)Spend up to t seconds running, choosing walkway and plain sections, to minimize travel time over a corridor of length X.Medium5GreedySortingNo attempts yet5s512 MBJudgeable
Music Collection SearchFor each song name, find the shortest case-insensitive substring that appears in that name alone, breaking ties by a custom lexicographic order.Medium5String matchingBrute force+1No attempts yet5s512 MBJudgeable
Vanishing Numbers (Small)Sort each decimal by the round it is removed from the Cantor middle-third process, placing numbers that never vanish last.Medium5MathSortingNo attempts yet5s512 MBJudgeable
Closing the Loop (Large)Pick equal numbers of red and blue rope segments to maximize total length minus one centimeter per knot.Medium5GreedySortingNo attempts yet5s512 MBJudgeable
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.Medium5GreedySorting+2No attempts yet5s512 MBJudgeable
Crazy Rows (Large)Given a binary N x N matrix, swap adjacent rows to move every 1 to or below the main diagonal, and output the minimum number of swaps.Medium5GreedySorting+1No attempts yet5s512 MBJudgeable
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 ?.Medium5ArraySorting+2No attempts yet2s128 MBJudgeable
Branch AssignmentPartition b branches into s nonempty groups to minimize total round-trip courier distance, where a message from branch i to j costs dist(i,hq)+dist(hq,j).Medium5GraphShortest path+1No attempts yet5s512 MBJudgeable
Seat AssignmentAssign seats left to right, each time giving the seat to the still-unseated request with the smallest right endpoint that covers it.Medium5GreedySorting+1No attempts yet0.8s32 MBJudgeable
Junseo the Librarian KingGiven book numbers and weights, move the lightest total weight of books so the numbers end up in non-decreasing order.Medium5Dynamic programmingSorting+2No attempts yet2s512 MBJudgeable
Birthday PresentsPick a subset of presents whose price range is below D, maximizing total satisfaction.Medium5SortingSliding window+2No attempts yet2s512 MBJudgeable
Centipede legsGiven n and m notes, choose left and right leg counts summing to n, both at least 1, maximizing how many notes have l_i <= left and r_i <= right, breaking ties by smallest left count.Medium5MathPrefix sum+2No attempts yet2s512 MBJudgeable
DNA SequencingEach printed line can be trimmed to any prefix; pick prefixes of length at least M so the number of distinct resulting strings is maximized.Medium5TrieString+2No attempts yet2s512 MBJudgeable
Change a PasswordGiven an old N-digit password, find the length-N permutation of distinct digits that maximizes the cyclic distance from the old value, breaking ties by smallest number.Medium5Brute forceSorting+2No attempts yet5s512 MBJudgeable
Minimum SwapsGiven permutations A and B, find the minimum number of swaps within A that turn it into B.Medium5ArrayHash map+2No attempts yet1s64 MBJudgeable
Presidential ElectionsGiven per-state delegates, fixed votes, and undecided voters, find the minimum number of undecided voters to convince so the Constituents win a delegate majority, with ties going to the Federals.Medium5GreedySortingNo attempts yet5s512 MBJudgeable
Soccer GameGiven n teams and their reported win counts in a round-robin with no ties, decide if some set of match results produces exactly those scores.Medium5GreedySortingNo attempts yet2s512 MBJudgeable
Mário's LockersGiven the positions of L free lockers, find the minimum number of swaps to gather N of them into consecutive positions.Medium5Sliding windowPrefix sum+2No attempts yet1s512 MBJudgeable
Shuffled DeckFor a deck of P distinct cards, find how many times the given interleaving shuffle must be repeated until the deck returns to its sorted order.Medium5MathSorting+1No attempts yet2s512 MBJudgeable
Grandpa Pepe's PizzaGiven N olive positions on a circle of circumference C, decide whether equal sectors of length C/N can each contain exactly one olive.Medium5MathImplementation+1No attempts yet2s512 MBJudgeable
FocusGiven N closed intervals, find the minimum number of points needed so that every interval contains at least one chosen point.Medium5GreedyIntervals+2No attempts yet2s512 MBJudgeable
University CourseSimulate course selection each semester: from courses whose prerequisites are done, take up to M with highest priority, and report the schedule.Medium5Topological sortGreedy+2No attempts yet2s512 MBJudgeable
Sentence ReductionGiven tasks with weekday, start and end times, and point values, pick a non-overlapping set that maximizes total points, and report the per-day breakdown.Medium5Dynamic programmingSorting+2No attempts yet2s512 MBJudgeable
Postal DeliveryGiven delivery counts at coordinates on a line and a truck capacity K, find the minimum total distance to deliver all letters and return to the origin.Medium5GreedySorting+1No attempts yet2s512 MBJudgeable
AssignmentsGiven deadlines and scores for N assignments, pick a subset schedulable within their deadlines to maximize total score.Medium5GreedySorting+2No attempts yet1s256 MBJudgeable
TaxFind the shortest path from S to D in a weighted undirected graph, then report it again after each tax rise adds p to every edge.Medium5Shortest pathGraph+2No attempts yet2s256 MBJudgeable
Reading ListTotal lifted books over a sequence of assignments, where each assigned book moves to the top of the tower.Medium5ArraySorting+2No attempts yet1s128 MBJudgeable
HNLGiven N clubs with points and one final round of matches, list every club that can still finish first under some set of results.Medium5Brute forceSorting+1No attempts yet1s128 MBJudgeable
HackerBuild the minimal list of URLs that covers every known parameter with every malicious value, packing pairs into queries of at most P parameters by the given grouping rule.Medium5ImplementationString+2No attempts yet1s128 MBJudgeable
Ć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.Medium5SimulationSorting+1No attempts yet3s128 MBJudgeable
MoocastGiven N cow coordinates, find the smallest integer X such that the graph connecting pairs whose squared distance is at most X is connected.Medium5GraphUnion-find+2No attempts yet2s512 MBJudgeable
Smallest sum no subsequence can makeGiven N ≤ 20 numbers, find the smallest natural number that is not the sum of any non-empty subsequence.Medium5BacktrackingBrute force+1No attempts yet2s512 MBJudgeable
The Ruthless BossGiven n distinct deadlines, find the largest integer k so that scheduling all jobs, each taking exactly k hours back to back, meets every deadline.Medium5GreedySorting+2No attempts yet2s512 MBJudgeable
Connecting Edges 2Given a weighted edge list, pick the order of adding edges that makes the total weight added up to the moment s and t first become connected as small as possible.Medium5GraphSorting+2No attempts yet2s512 MBJudgeable
Watson and Intervals (Small)Generate N intervals from a recurrence, then remove exactly one interval so the number of integers covered by the rest is minimized.Medium5IntervalsSorting+1No attempts yet5s512 MBJudgeable
Convenience Store 2Given n customer points, place one store anywhere to minimize the total Manhattan distance to all customers and print that minimum sum.Medium5MathSorting+2No attempts yet2s512 MBJudgeable
SprinklersPlace two fixed sprinklers and choose radii so every flower is covered, minimizing the sum of squared radii; print that minimum as an integer.Medium5SortingGreedy+2No attempts yet2s512 MBJudgeable
ParetoChoose k accounts maximizing B minus A, where A = 100k/N and B is their share of all money as a percent.Medium5GreedySorting+2No attempts yet1s64 MBJudgeable
Junoh Lives for Lunch!!Given each friend's starting position and running speed, decide whether all N friends can meet at one point within time T.Medium5Binary searchSorting+2No attempts yet2s512 MBJudgeable
Voter DepressionPick non-overlapping story intervals to multiply exposed voters' propensities and maximize the right-minus-left propensity gap.Medium5Dynamic programmingIntervals+1No attempts yet2s512 MBJudgeable
Shoemaker's Job OrderOrder N jobs to minimize the total fine paid while each job waits, using the shortest processing time per fine ratio first, with lexicographically smallest ties.Medium5GreedySortingNo 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
Best Relay TeamChoose four runners from n, assign one to leg 1 and three to the other legs, minimizing the total time with a lexicographic tie-break.Medium5GreedySorting+1No attempts yet1s512 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
Robot Energy Source OrderReorder n energy sources, each with acceleration a_i and duration s_i, to maximize total distance, and print the gain over the given order.Medium5SortingGreedy+2No attempts yet0.2s128 MBJudgeable
The StoveEach visitor stays for one time unit at a distinct arrival time; with at most K lights, minimize total stove-on time by skipping the largest idle gaps.Medium5GreedySorting+1No attempts yet1s256 MBJudgeable
Art ExhibitionChoose a subset of artworks maximizing the sum of values minus the difference between the largest and smallest sizes in the subset.Medium5SortingPrefix sum+1No attempts yet1s256 MBJudgeable
Signal 1Choose a subset of points with distinct x-coordinates; maximize the total Euclidean length of the polyline joining them in increasing x order.Medium5Dynamic programmingSorting+2No attempts yet1.5s128 MBJudgeable
Largest averageGiven N grades, repeatedly replace any two numbers with their average until one remains; find the largest possible final value.Medium5GreedyMath+2No attempts yet1s64 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
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
Rest StopsBessie rests at grass stops along a trail and must never fall behind Farmer John; maximize total tastiness of eaten grass.Medium5GreedySorting+2No attempts yet2s512 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
*Light*Young*Woo*Given N lights that each illuminate a 90-degree upward sector, count for each query point how many sectors contain it.Medium5GeometryPrefix sum+2No attempts yet1s512 MBJudgeable
Warring StatesProcess alliance and war records between groups, merging by sum for alliances and subtracting troops for wars, then report surviving groups sorted by troop count.Medium5Union-findImplementation+2No attempts yet1s128 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
5th Job AdvancementOrder n quests and toggle at most k active Arcane Stones to split each quest reward among run lengths, maximizing total collected experience.Medium5SortingPrefix sum+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
RectanglesChoose pairs of sticks (each possibly shortened by at most 1) as opposite sides of rectangles, maximizing the total area.Medium5GreedySorting+2No attempts yet2s512 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
Amusement ParkCitizens at various blocks must reach block 0 by taxi (A per block, one rider) or by sharing a bus (B won, up to 40 riders, one pick-up point). Find the minimum total cost.Medium5Dynamic programmingSorting+2No attempts yet1s256 MBJudgeable
Sheep Rescue OperationGiven a tree rooted at 1 with sheep or wolf counts per node, find the maximum number of sheep that can reach node 1 along unique paths while each wolf eats at most one entering sheep.Medium5TreeGreedy+2No attempts yet1s256 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
PokegeneCount, for each query, how many string prefixes occur in exactly L of the K listed genomes.Medium5StringString matching+1No attempts yet2s512 MBJudgeable
Lipschitz ConstantGiven N points (x, f(x)), the Lipschitz constant is the maximum slope between adjacent points after sorting by x.Medium5GeometrySorting+1No 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
SiblingsGiven each woman's mother as an index, count pairs of women who share the same mother across several data sets.Medium5Hash mapSorting+1No attempts yet2s512 MBJudgeable
Mountain ViewCount how many mountain peaks are not covered by any other 45-degree right-triangle mountain with its base on the x-axis.Medium5GeometrySorting+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