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,741 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Space AntGiven N points with distinct x and y coordinates, output the order produced by repeatedly picking the most clockwise remaining point from the current one.Medium5GeometrySorting+2No attempts yet1s128 MBJudgeable
Wooden SticksGiven n sticks with length and weight, order them to minimize the number of setup steps, where a setup is needed unless both length and weight are nondecreasing from the previous stick.Medium5SortingGreedy+1No attempts yet1s128 MBJudgeable
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.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
Bin PackingPack items into identical bins holding at most two items each so that the number of bins is minimized.Medium5GreedyTwo pointers+2No attempts yet1s128 MBJudgeable
DancersRepeatedly pair the two closest unpaired dancers, breaking ties by smaller indices, and output all pairs sorted.Medium5SortingGeometry+2No attempts yet1s128 MBJudgeable
Olympic GamesGiven each event's date and start and end times in hhmm, find the maximum number of events a person can attend without overlap, moving freely between venues.Medium5GreedySorting+2No attempts yet2s256 MBJudgeable
CocktailsSimulate Angelo's cocktail mixing rules, track each cocktail's counts, and print the top ten by count then recipe-book order with computed prices.Medium5SimulationHash map+2No attempts yet1s128 MBJudgeable
FactoryGiven two orderings of the same N numbers, count pairs of connecting cables that cross when drawn as straight lines.Medium5SortingPrefix sum+1No attempts yet1s256 MBJudgeable
Saruman's ArmyPlace the fewest palantirs on troop positions so every troop lies within range R of one.Medium5GreedySorting+1No attempts yet1s128 MBJudgeable
OutletsGiven power strips that swap between standard A and B outlets, find the maximum number of standard-A outlets that can end up powering computers.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
Romantic DateGiven Wibowo's 26 cards, find the maximum number of rounds he can win by pairing his cards against his opponent's 26 cards in the best order.Medium5GreedySorting+1No attempts yet1s128 MBJudgeable
Random GapGiven a linear congruential generator, find the largest gap between neighboring distinct values the sequence produces.Medium5SimulationHash map+2No attempts yet4s128 MBJudgeable
SkyscrapersFor each queried day, count maximal blocks of adjacent skyscrapers whose heights exceed the rising sea level.Medium5SortingArray+1No attempts yet2s128 MBJudgeable
Tiling VerificationGiven a floor and up to 100 rectangles, decide whether they overlap, stick out of the floor, or fail to cover it, printing which condition fails first.Medium5GeometryImplementation+2No attempts yet1s128 MBJudgeable
SortingCount the swaps made by a given selection-style double loop on an array.Medium5SortingArray+1No attempts yet1s128 MBJudgeable
ChocolateFind the minimum total cost to split an m by n chocolate bar into unit squares, where each vertical or horizontal cut costs a fixed price regardless of the piece size.Medium5GreedySortingNo attempts yet1s128 MBJudgeable
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.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
BalanceGiven weights, split some into two equal-sum disjoint groups; find the largest weight that can be the heaviest used one.Medium5Dynamic programmingSorting+2No attempts yet3s128 MBJudgeable
LollobrigidaGiven a multiset of block heights, decide whether the blocks can be arranged so the sequence alternates up and down at every position.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
Building BlocksRemove blocks from a tower so the most remaining blocks sit at an altitude equal to their printed number.Medium5Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
Building BlocksFind the minimum number of add/remove block moves so that some k consecutive columns end up with equal height.Medium5Sliding windowPrefix sum+2No attempts yet1s128 MBJudgeable
MapCount the marked points that have at least one point strictly below-left, above-right, below-right, and above-left of them.Medium5SortingArrayNo attempts yet1s128 MBJudgeable
Logarithmic PaprikaGiven counts of paprika weighing 1, 2, 4, ..., 2^k grams, find the smallest positive weight that cannot be formed from whole pieces.Medium5GreedyMath+2No attempts yet1s128 MBJudgeable
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.Medium5SortingBinary search+2No attempts yet1s128 MBJudgeable
BalloonsGiven stock counts for n balloon colors and m orders, decide whether each child can receive the requested number of distinct-colored balloons.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
ElectricityGiven k lines between n homes and m windmills on parallel lines, count subsets of non-crossing lines where every home and windmill has degree at most one, modulo r.Medium5Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
Crime at Piccadilly CircusFor each integer moment in [p, k], count how many people's inclusive intervals cover it, and report the minimum and maximum counts.Medium5IntervalsSorting+2No attempts yet1s128 MBJudgeable
Galactic Container ShipGiven M rails with height limits 1..M and N plates each worth its quality w and having height h, choose plates to maximize total quality so that each chosen plate fits some distinct rail.Medium5GreedySorting+1No attempts yet1s128 MBJudgeable
BrothersChoose the largest set of families whose position spans never overlap so each kept family stands together.Medium5GreedyIntervals+1No attempts yet1s512 MBJudgeable
Telephone ExchangePick an integer tower height so the fees from houses fully covered by the circle exceed the height-dependent maintenance cost by as much as possible.Medium5GeometrySorting+2No attempts yet1s512 MBJudgeable
Planting PotatoesDistribute up to m potatoes over fields capped at b_i so the sum of squared counts is as large as possible.Medium5GreedySortingNo attempts yet1s128 MBJudgeable
Paper RollsSet every roll to one shared unrolled length within each total length using the fewest 1-cm moves.Medium5SortingMathNo attempts yet1s128 MBJudgeable
The CrossingPair at most two riders per shared boat within the weight limit or send each alone, and find the lowest total fare.Medium5GreedySorting+1No attempts yet2s128 MBJudgeable
Word Translation LookupGiven pairs of directly translated words, list every target-language word linked to each query word through translation chains.Medium5Union-findHash map+1No attempts yet12s128 MBJudgeable
Portal KombatHektor absorbs the strength of each weaker opponent he beats, and the goal is the fewest wins that let him defeat the strongest opponent.Medium5GreedySorting+1No attempts yet5s128 MBJudgeable
MinersAssign each miner to a leaf chamber whose path from the entrance stays tall enough and fit as many miners as possible.Medium5GreedySorting+1No attempts yet2s128 MBJudgeable
MeteorThe task counts the largest number of meteors strictly inside a fixed rectangle at one moment as each meteor moves along a straight path.Medium5IntervalsSorting+1No attempts yet1s128 MBJudgeable
SymmetryDecide whether the given dots mirror exactly across some vertical line, printing YES or NO for each test case.Medium5Hash mapGeometry+1No attempts yet1s128 MBJudgeable
Parcel DeliveryChoose how many boxes of each shipment to load onto a one-way truck of capacity C to maximize total delivered boxes.Medium5GreedySortingNo attempts yet1s128 MBJudgeable
TaekwondoSort both weight lists and pair players to minimize the total absolute weight difference across all matches.Medium5Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
BridgeFind the bridge height that minimizes the total crossing distance over every pair of left and right houses.Medium5SortingMathNo attempts yet3s128 MBJudgeable
Canoe AthletesPick one weight from each of four lists so the total is closest to the target, preferring the smaller total on ties.Medium5Binary searchSorting+1No attempts yet3s256 MBJudgeable
Sum of Two NumbersCount the pairs of distinct given integers whose sum has the smallest absolute difference from K.Medium5Two pointersSortingNo attempts yet1s128 MBJudgeable
Widest PathFind the path between two given nodes whose smallest edge weight is as large as possible.Medium5Minimum spanning treeUnion-find+1No attempts yet1s128 MBJudgeable
Message BroadcastingCompute the fewest rounds to spread a message from the root when each informed node calls at most one child per round.Medium5GreedyTree+2No attempts yet1s128 MBJudgeable
RankingsPlayers accumulate points through updates and each query asks for the current rank of one player among up to 100000 players.Medium5Segment treeSorting+1No attempts yet3s128 MBJudgeable
Wiring CostPay for wire pieces so every cheaper piece becomes free, then choose the price tier that reaches the required length at the lowest cost.Medium5GreedySortingNo attempts yet1s128 MBJudgeable
Shuttle BusFind the smallest fleet of buses that can run every scheduled trip between the school and the terminal given the one-way travel time.Medium5GreedySortingNo attempts yet1s128 MBJudgeable
Tiling Up BlocksFind the largest subset of blocks that stacks so both knob counts never decrease from bottom to top.Medium5Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
Bonus WordFind every pair of dictionary words that joins to ten letters and matches each query fixed and shuffled letters, listed in order.Medium5StringBrute force+1No attempts yet1s128 MBJudgeable
The Tired Traveling SalesmanFind the integer point off all customer sites that minimizes total Manhattan distance and count how many such points tie.Medium5SortingMath+1No attempts yet1s128 MBJudgeable
Nested Shrubbery BoxesChoose the largest subset of boxes that nest when every box is rotated to fit strictly inside the next box.Medium5Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
Hierarchical DemocracyCompute the smallest popular vote total that wins the presidency through nested majority votes in districts.Medium5TreeGreedy+1No attempts yet1s128 MBJudgeable
Pretty good numbersCount the integers in each interval whose absolute gap between the proper-divisor sum and the number is within the limit.Medium5Number theorySorting+1No attempts yet1s128 MBJudgeable
Property LinesGiven up to 100 claimed rectangles inside a W by H city, compute the area claimed twice or more, at least once, and never.Medium5GeometryBrute force+1No attempts yet1s128 MBJudgeable
MI6Given an integer, output its prime power components, one per prime factor, in increasing order.Medium5Number theorySortingNo attempts yet1s128 MBJudgeable
RoadDecide whether the road between p and q can belong to a cheapest network that connects all cities.Medium5Minimum spanning treeUnion-find+1No attempts yet2s64 MBJudgeable
Manhattan SortSort each sequence of distinct integers with swaps that cost the distance between positions and report the minimum total cost.Medium5GreedySorting+1No attempts yet1s128 MBJudgeable
Adding NumbersSplit the given digits into two numbers with no leading zero so their sum is as small as possible.Medium5Brute forceSorting+1No attempts yet1s128 MBJudgeable
Permutation GraphGiven two permutations of 1 to n drawn on two parallel lines, count the pairs of segments joining equal numbers that cross.Medium5Divide and conquerSortingNo attempts yet5s256 MBJudgeable
Farmer John has no large brown cowFind the Kth adjective combination in alphabetical order among all combinations except the N forbidden ones.Medium5CombinatoricsSortingNo attempts yet1s128 MBJudgeable
Crowded CowsCount cows that have a cow at least twice as tall within distance D on both the left and the right.Medium5Sliding windowSorting+1No attempts yet1s128 MBJudgeable
Trending TopicMaintain word counts over a rolling 7-day window and answer each top N query in frequency order with ties included.Medium5Sliding windowHash map+1No attempts yet1s128 MBJudgeable
Minimum Cost SortingFind the cheapest total of moved values needed to sort the array when moving one element to any position costs its value.Medium5Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
Search SuggestionFor each typed prefix, print the three highest-scoring matching cities, or the match count when more than 1000 names match.Medium5Binary searchString+1No attempts yet1s128 MBJudgeable
Global WarmingGiven column heights, find the greatest number of maximal above-water runs over all real sea levels.Medium5Union-findSorting+1No attempts yet2s512 MBJudgeable
Super PhyllisFind every direct reporting edge that has an alternate route through at least one other person and print those edges in sorted order.Medium5GraphShortest path+1No attempts yet2s128 MBJudgeable
Milk SchedulingSchedule at most one cow per time unit before its deadline to maximize total gallons of milk.Medium5GreedyHeap+1No attempts yet1s128 MBJudgeable
Cow BaseballCount triples of cows in increasing position whose second gap is at least the first gap and at most twice it.Medium5Two pointersSortingNo attempts yet1s128 MBJudgeable
Cross Country SkiingFind the smallest elevation gap D that keeps every waypoint mutually reachable through adjacent cells.Medium5Minimum spanning treeUnion-find+1No attempts yet1s512 MBJudgeable
Recording the MoolympicsSelect the largest set of programs that two tuners can record when one tuner cannot record overlapping programs.Medium5GreedySorting+1No attempts yet1s128 MBJudgeable
Incomparable rectangle pairsCount the pairs of rectangles where neither fits inside the other after translation or a 90-degree rotation.Medium5SortingGeometry+1No attempts yet2s512 MBJudgeable
Stacking BlocksReshape both towers into the V-shaped skyline with center height h at the lowest total cost of added and removed blocks.Medium5SortingPrefix sum+1No attempts yet1s128 MBJudgeable
Fair PhotographyAfter sorting cows by position, find the widest interval with equal numbers of G and H cows, where single-breed intervals also count.Medium5Prefix sumHash map+1No attempts yet1s128 MBJudgeable
Gondola ReplacementGiven the n cars seen on a circular gondola line, find one possible order of breakdowns that explains the observed numbers.Medium5SortingHash mapNo attempts yet1s256 MBJudgeable
Where's That Fuel?Starting with planet P's fuel, repeatedly visit affordable planets to maximize final fuel, then the number of visits.Medium5GreedySorting+1No attempts yet2s256 MBJudgeable
Market ShoppingYou choose exactly k prices per query to maximize the odd total, printing -1 when no odd sum exists.Medium5GreedySorting+1No attempts yet10s256 MBJudgeable
Crossing the RiverPick a booster range and rock hops that cross the river with the lowest range-squared plus per-jump cost.Medium5GreedySortingNo attempts yet1s256 MBJudgeable
Opening CeremonyGiven each block height, find the fewest charges that clear all blocks with whole-block shots and level-wide shots.Medium5SortingGreedyNo attempts yet1s256 MBJudgeable
Clock PhotosDecide whether two sets of hand angles on a dial coincide after rotating one photo.Medium5SortingString matchingNo attempts yet1s256 MBJudgeable
Hexagonal colonyChoose hexagonal cell blocks so the exposed wall windows house at least P people with the fewest blocks.Medium5GreedyGeometry+2No attempts yet1s256 MBJudgeable
StavitelA cube building on a square board must match given front and right skyline heights; find the minimum and maximum possible cube counts.Medium5GreedySorting+1No attempts yet1s256 MBJudgeable
Rat TunnelPick the cheapest lanes for cameras so every closed running route holds one, and report the total cost and the longest chosen lane.Medium5Minimum spanning treeUnion-find+1No attempts yet1s256 MBJudgeable
DebtFor every group size M, choose M loans to minimize M times the largest chosen loan minus their sum, and output the total of these minima.Medium5SortingPrefix sumNo attempts yet1s256 MBJudgeable
Burrito KingChoose fractional amounts of capped ingredients to maximize joy without exceeding the unhappiness budget, and print every value as a reduced fraction.Medium5GreedySorting+1No attempts yet1s256 MBJudgeable
Learning by ExampleCount how many integer weights from A to B the nearest-neighbor classifier labels as spotted from N labeled training weights.Medium5SortingIntervalsNo attempts yet1s256 MBJudgeable
StampedeCount how many moving segments are ever the closest to the origin while crossing the positive y-axis.Medium5IntervalsSorting+1No attempts yet1s256 MBJudgeable
Arctic Polar ExplorerWrite an APECODE program that makes a robot with two grippers sort a line of rocks by weight using only balance comparisons.Medium5SortingSimulation+2No attempts yet1s256 MBJudgeable
Color BallsFor each ball, add up the sizes of all strictly smaller balls with a different color.Medium5SortingPrefix sum+1No attempts yet1s256 MBJudgeable
Maximize DifferencesReorder the given array so the sum of absolute differences between neighbors is as large as possible.Medium5GreedySorting+1No attempts yet1s256 MBJudgeable
Museum wall constructionFind the shortest closed curve enclosing N disjoint equal circles of radius R.Medium5GeometrySortingNo attempts yet1s256 MBJudgeable
Butterfly BallotDecide whether the candidates can be ordered so candidate 1 finishes first when half of each ballot position's supporters spill to the next position.Medium5GreedySorting+1No attempts yet1s256 MBJudgeable
TV WarPick non-overlapping weekly TV programs to maximize the total preference score.Medium5Dynamic programmingSorting+2No attempts yet1s256 MBJudgeable
Traffic VolumeCount how many cars came from the left from the unordered times in two boxes with offsets of 500, 1000, and 1500.Medium5GreedySorting+1No attempts yet1s256 MBJudgeable
Guarding the BorderAdd up to M towers anywhere on a circular border of length L so the largest gap between neighboring towers is as small as possible.Medium5Binary searchGreedy+1No attempts yet3s256 MBJudgeable
Bank QueuePick at most one person per minute before each deadline to maximize the total cash collected.Medium5GreedyHeap+1No attempts yet1s256 MBJudgeable
LineagePick a father and a mother from the given gene values so the nearest of the three pups' gene values to R is as close as possible.Medium5SortingBinary searchNo attempts yet1s256 MBJudgeable
Entertainment BoxSchedule the most TV shows on k recorders so no recorder tapes overlapping shows.Medium5GreedySorting+1No attempts yet2s256 MBJudgeable
Population MigrationResidents buy each job from the priciest affordable worker and leave when daily income falls below outside earnings; count who stays once departures stop.Medium5SimulationSortingNo attempts yet5s256 MBJudgeable
Number of distinct substringsCount how many different contiguous substrings appear in a lowercase string of length up to 1000.Medium5String matchingHash map+1No attempts yet1s512 MBJudgeable