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
Triangle SubsequenceGiven a sequence, find the longest subsequence where every triple of elements satisfies the triangle inequality.Medium5SortingTwo pointers+1No attempts yet2s128 MBJudgeable
Counting Crossing EdgesGiven M cross edges between two labeled vertex sets of size N, count how many unordered pairs of edges cross each other.Medium5SortingDivide and conquer+2No attempts yet2s128 MBJudgeable
Sungji's Birthday PartyGiven N students each requiring a minimum number of other attendees to be satisfied, find the smallest group of students that can be invited so every invited student's requirement is met.Medium5GreedySorting+1No attempts yet2s128 MBJudgeable
City Division PlanSplit a connected weighted graph into two connected subvillages by removing edges so that the total remaining maintenance cost is minimized.Medium5Minimum spanning treeUnion-find+2No attempts yet2s256 MBJudgeable
Running MedianGiven integers one by one, output the running median (lower of the two middles when count is even) after each insertion.Medium5HeapSorting+1No attempts yet0.1s128 MBJudgeable
Dasom's Shoe StoreChoose which discount coupons to buy, given their price and 1-3% discount rate, to minimize the total cost paid for a shoe.Medium5GreedySorting+2No attempts yet2s128 MBJudgeable
Convex HullCompute the convex hull of up to 100,000 points and count only the hull's true vertices, excluding collinear boundary points.Medium5GeometrySorting+1No attempts yet2s128 MBJudgeable
LaserGroup buildings by the ray from the origin, sort each group by distance, and find buildings whose laser is blocked by a closer, equally tall or taller building.Medium5GeometrySorting+2No attempts yet2s128 MBJudgeable
Number GroupingGiven N integers, decide which pairs to multiply instead of add so that the resulting total sum is maximized.Medium5GreedySorting+1No attempts yet2s128 MBJudgeable
Balanced LineupGiven fans sorted by x-coordinate with a gender bit each, find the longest contiguous segment that has an equal number of men and women.Medium5Prefix sumHash map+2No attempts yet2s256 MBJudgeable
Designing a High-Speed Rail NetworkGiven a cost matrix where negative values mark already-built rail lines, compute the minimum spanning tree cost forcing existing lines and list the new lines to build.Medium5Minimum spanning treeUnion-find+2No attempts yet2s128 MBJudgeable
Assigning RanksAssign each of N students a unique rank from 1 to N to minimize the total absolute difference from their expected ranks.Medium5GreedySortingNo attempts yet2s256 MBJudgeable
Covering a SegmentGiven up to 100,000 segments on a line, find the minimum number needed to fully cover [0, M], or output 0 if impossible.Medium5GreedyIntervals+1No attempts yet2s128 MBJudgeable
Interval Containing the Most OthersGiven N intervals with unique endpoints, find the maximum number of intervals strictly contained inside a single interval.Medium5SortingBinary search+1No attempts yet2s128 MBJudgeable
Super 12Simulate a rugby league by computing bonus points, sorting standings after every full round, and printing formatted tables.Medium5SimulationSorting+1No attempts yet1s128 MBJudgeable
Similar WordsGiven up to 20,000 distinct words, find the pair with the longest common prefix, breaking ties by input order.Medium5StringSorting+1No attempts yet2s128 MBJudgeable
Sum of Three NumbersGiven up to 1000 distinct integers, find the largest set element expressible as a sum of three elements (repeats allowed).Medium5Two pointersSorting+1No attempts yet1s128 MBJudgeable
Placing a Basketball HoopFind the integer point minimizing the sum of weighted Manhattan distances to given weighted points, breaking ties by smallest x then smallest y.Medium5MathSorting+1No attempts yet2s128 MBJudgeable
Pipe CuttingGiven M long pipes and N required short pipe lengths, compute the maximum number of short pipes that can be cut from the long pipes.Medium5GreedySortingNo attempts yet2s128 MBJudgeable
Three SolutionsGiven up to 5000 distinct integers, find three distinct values whose sum is closest to zero, using sorting and two-pointer scanning.Medium5Two pointersSorting+1No attempts yet1s256 MBJudgeable
Electric WiresGiven wires connecting positions on two poles, find the minimum removals so remaining wires never cross, equivalent to n minus the longest increasing subsequence.Medium5Dynamic programmingBinary search+1No attempts yet1s128 MBJudgeable
Minimum Cost for Restaurant OrdersGiven first-dish and later-dish prices for N dishes, compute for every k the minimum total cost of ordering exactly k dishes.Medium5GreedySorting+1No attempts yet2s256 MBJudgeable
Number GameAfter each new pair of numbers arrives, pair sorted A values with reverse sorted B values and output the minimum possible maximum sum, updating online for each round.Medium5GreedySorting+1No attempts yet1s128 MBJudgeable
AvogadroGiven a 3xN table where row 1 is a permutation of 1..N, find the minimum number of columns to delete so the three rows can be made identical after sorting each row.Medium5GreedyArray+1No attempts yet1s128 MBJudgeable
Concert Rest ScheduleSchedule N members' fixed-length rest intervals within a T-minute concert so that at most two intervals overlap at any moment.Medium5GreedyIntervals+1No attempts yet1s128 MBJudgeable
Non-Intersecting CirclesGiven N circles centered on the x-axis, find the minimum number to remove so no two remaining circles overlap, essentially an interval scheduling problem.Medium5GreedyIntervals+1No attempts yet1s128 MBJudgeable
Cinema InvitationGiven each friend's minimum required number of other attending friends, find the smallest subset size satisfying everyone invited's threshold.Medium5GreedySorting+1No attempts yet1s128 MBJudgeable
JANICAReconstruct running leader times from cumulative differences over two ski rounds to find the top three finishers by total time.Medium5SimulationSorting+1No attempts yet1s128 MBJudgeable
Safe LockGiven N positions on a circular ring of size 10,000,000, find the minimum total distance to move all points to a common position, minimizing sum of circular distances.Medium5SortingPrefix sum+2No attempts yet1s128 MBJudgeable
Printed Circuit BoardGiven N wires each connecting a bottom-edge point to a top-edge point, find the minimum number of layers so that crossing wires never share a layer, which reduces to finding the maximum count of pairwise-crossing wires.Medium5SortingBinary search+1No attempts yet1s128 MBJudgeable
Matching BinsGiven a sequence of bin sizes, find the largest K such that the first K bins can each be matched to a distinct larger bin among the following K bins.Medium5Binary searchGreedy+1No attempts yet1s128 MBJudgeable
Hands of PokerGiven a five card poker hand, compute its unique rank value from 1 to 7462 that orders all possible hands consistently.Medium5SortingHash map+1No attempts yet1s128 MBJudgeable
Defense of a KingdomGiven tower positions that block whole rows and columns on a grid, find the area of the largest rectangle of cells left undefended.Medium5SortingGreedy+1No attempts yet3s256 MBJudgeable
Key to SuccessGiven n existing coin values and m coins to add freely, choose the added values to maximize the smallest positive integer not representable as a subset sum.Medium5GreedyMath+1No attempts yet3s256 MBJudgeable
Simple PolygonOrder given points into a specific simple polygon by picking a bottom-most anchor and sorting the rest by polar angle with a special tie-break for collinear groups.Medium5GeometrySorting+1No attempts yet1s128 MBJudgeable
Maximum SumGiven n boxes of numbered balls, pick at most one ball per box in order to form a non-decreasing sequence with maximum possible sum.Medium5Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
Windmill AnimationSimulate a line rotating counter-clockwise about a pivot point, switching pivot whenever the line hits another of the given points, and report the first S pivots. Repeat for each dataset.Medium5GeometrySimulation+2No attempts yet1s128 MBJudgeable
Emma Loves PartiesGiven parties as hourly intervals, find the most Emma can attend if she stays at least 30 minutes at each one.Medium5GreedySorting+1No attempts yet1s128 MBJudgeable
BalloonsAllocate balloons from two rooms to teams with given distances so total delivery distance is minimized.Medium5GreedySortingNo attempts yet1s128 MBJudgeable
Buying GasChoose the fewest gas stations to stop at so the car never runs out of gas over a trip of length d with tank range 10n.Medium5GreedySorting+1No attempts yet1s128 MBJudgeable
Frosh WeekGiven n distinct student numbers in a line, find the minimum number of adjacent swaps needed to sort them into increasing order.Medium5SortingDivide and conquer+2No attempts yet1s128 MBJudgeable
Open SourceCount distinct students per project, drop any student who signed up for more than one project, then sort projects by count descending and name.Medium5Hash mapSorting+2No attempts yet1s128 MBJudgeable
Tour de FranceGiven front and rear sprocket tooth counts, find the maximum ratio between adjacent attainable drive ratios n/m across all pairs.Medium5SortingMath+2No attempts yet1s128 MBJudgeable
Team RankingsGiven up to 100 rankings of five teams, find the ranking minimizing the sum of pairwise-order disagreements, breaking ties alphabetically.Medium5Brute forceCombinatorics+2No attempts yet1s128 MBJudgeable
Genealogical ResearchProcess birth and death records, then answer ancestor and descendant queries by printing the family tree recursively with dates.Medium5RecursionTree+2No attempts yet1s128 MBJudgeable
Hippity HopscotchOn an n by n grid of penny stacks, starting at (0,0) and jumping up to k cells in a row or column to a strictly larger stack, find the maximum total collected.Medium5Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
Games R UsGroup users into equivalence classes by identical directory access sets, then report classes of size 2 or more.Medium5Hash mapSorting+2No attempts yet1s128 MBJudgeable
Know When to Hold ThemRank a set of five-card poker hands from most to least valuable, using nine standard hand categories and their tie-breakers.Medium5SortingImplementation+2No attempts yet1s128 MBJudgeable
The Extent of the ProblemSimulate RADDD's two-step defragmentation passes over disk blocks and output the final extent layout of every file.Medium5SimulationImplementation+2No attempts yet1s128 MBJudgeable
Blue JeansGiven up to 10 DNA strings of length 60, find the longest substring that appears in all of them, breaking ties alphabetically, or report none of length 3 or more.Medium5StringBrute force+2No attempts yet1s128 MBJudgeable
Index GenerationParse markers in a multi-page document, collect page references for primary and secondary index entries, and print the index sorted case-insensitively.Medium5StringSimulation+2No attempts yet1s128 MBJudgeable
Sum It UpGiven a target and up to 12 numbers, list every distinct subset sum equal to the target, sorted in decreasing lexicographic order.Medium5BacktrackingSorting+2No attempts yet1s128 MBJudgeable
BalloonsAssign each team's balloons from rooms A and B, respecting supply limits, to minimize total travel distance.Medium5GreedySortingNo attempts yet1s128 MBJudgeable
Auctions R UsSimulate one day of auctions: process auctions by end time, deduct each winning bid from the bidder's balance, and report winners or unmet reserves.Medium5SimulationSorting+1No attempts yet1s128 MBJudgeable
Tangled in CablesCompute the minimum spanning tree of a town map and compare its total length against the available spool of cable.Medium5Minimum spanning treeGraph+2No attempts yet1s128 MBJudgeable
Emergency RoomSimulate an emergency room where doctors pick the waiting patient with the highest-priority next treatment, and report each patient's release time.Medium5SimulationHeap+2No attempts yet1s128 MBJudgeable
Stock PricesFor each test case, report the days with the k1 lowest prices (days ascending) and the k2 highest prices (days descending), breaking ties by a stated rule.Medium5SortingGreedy+1No attempts yet2s128 MBJudgeable
Dividing the LandFor each test case, split N cities with K-1 evenly spaced vertical or horizontal cuts, avoid cuts through cities, and print the minimum average |count - N/K| as a reduced fraction.Medium5SortingMath+2No attempts yet1s128 MBJudgeable
Gift from the Goddess of ProgrammingEach log line records the entrance or exit of a visitor or the goddess (ID 000). Find the visitor who spends the most time at the altar while the goddess is present.Medium5SimulationSorting+2No attempts yet1s128 MBJudgeable
Analyzing Login/Logout RecordsGiven login and logout records on PCs, compute for each query how many minutes a student used at least one PC during a time interval.Medium5IntervalsSimulation+2No attempts yet1s128 MBJudgeable
Cut the CakeSimulate n vertical cuts on a rectangular cake, tracking each rectangular piece and reassigning ids by area, then print all final piece areas sorted.Medium5SimulationImplementation+2No attempts yet1s128 MBJudgeable
Dirty DrivingGiven distances to n cars ahead and a constant p, find the minimum gap to the nearest car so every car x ahead is at least p*(k+1) away, where k counts cars between.Medium5SortingGreedy+1No attempts yet1s128 MBJudgeable
ShopaholicGiven item prices, group them into triples so that the cheapest item in each triple is free, and maximize the total discount.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
Foreclosure BoroughFor each polygon borough, compute the percentage of houses inside it that are in foreclosure, sort boroughs by rate, and print two-decimal rates with tie-breaking by borough number.Medium5GeometrySorting+1No attempts yet1s128 MBJudgeable
The Perfect AlibiEach witness gives a suspect, a place, and a time interval; conflicting pairs are discarded, and we list suspects with no surviving witness covering the crime time.Medium5ImplementationSorting+2No attempts yet1s128 MBJudgeable
Problem-Free Problem SetGiven N problems, each covering some of M required algorithms, find the smallest subset of problems covering all M algorithms, breaking ties by lexicographic order of problem names.Medium5Bit manipulationBrute force+2No attempts yet1s128 MBJudgeable
Overlap!Given each course's exam day and time slot and each student's course list, count students who have two or more finals that overlap in time.Medium5ImplementationSorting+2No attempts yet1s128 MBJudgeable
Study DaysDistribute H study hours among n courses, each with 10 grade thresholds, to maximize the average grade point, rounded to two decimals.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
Yes or No?Pick between l and r questions to answer Yes, maximizing the sum of per-question expected correct probabilities, and report the maximum expectation to two decimals.Medium5Dynamic programmingSorting+2No attempts yet1s128 MBJudgeable
Throw a Party!!!Given friends' home regions with drunk/sober status and cars with capacity bound to regions, compute how many friends cannot be seated (each car needs a sober driver).Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
Time Is MoneyWe choose N-1 links forming a spanning tree minimizing SumTime*SumMoney, where each edge has a time and a money cost.Medium5Minimum spanning treeGeometry+2No attempts yet1s128 MBJudgeable
Jumbled LettersFor each query, find the longest dictionary word that can be formed using the query letters at most once, breaking ties alphabetically, or report IMPOSSIBLE.Medium5StringHash map+2No attempts yet1s128 MBJudgeable
Northwest WindCount pairs of islands where one can sail to the other moving only east or south (both coordinates monotone between the two points).Medium5SortingPrefix sum+2No attempts yet1s256 MBJudgeable
FloodgatesEach gate drains Fi per hour at fixed cost Ci when opened. For each query (V, T), find the minimum total cost whose combined capacity Fi*T covers V.Medium5Brute forceGreedy+2No attempts yet1s128 MBJudgeable
JolloGiven the Princess's three cards and two of the Prince's, find the smallest unused third card that lets the Prince win at least two rounds against any order of play.Medium5Brute forceGreedy+2No attempts yet1s128 MBJudgeable
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.Medium5SortingPrefix sum+2No attempts yet1s128 MBJudgeable
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.Medium5ArraySorting+2No attempts yet1s128 MBJudgeable
Child PlayGiven domino-like slabs, orient and order them so both rows sum equally, discarding one slab only if necessary and preferring the smallest minimum half.Medium5Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
IslandsGiven heights along a line, find the maximum number of separate exposed segments at any single rising water level.Medium5SortingArray+2No attempts yet1s128 MBJudgeable
Skewed SortingApply a recursive swap procedure on 2^N cows, comparing equal-length halves as base-2^N numbers, and report total distance moved plus final order.Medium5Divide and conquerRecursion+2No attempts yet1s128 MBJudgeable
Buying Feed, IIPick up to K pounds of feed from stores along a line, paying each store's price plus transport cost of distance carried, and minimize the total.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
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.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
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.Medium5GreedyArray+2No attempts yet1s128 MBJudgeable
SunscreenEach cow accepts an SPF interval, each bottle has an SPF value and capacity; assign bottles to maximize the number of cows covered.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
Radar InstallationEach island on the sea side of a line must be covered by radars of reach d placed on the line, so find the minimum number of placements or report -1 if some island is unreachable.Medium5GreedyIntervals+2No attempts yet1s128 MBJudgeable
Pearl PairingGiven counts of each pearl color, output the canonical pairing that matches the pearl at position i with the pearl at position i + N/2 in sorted order.Medium5GreedySorting+2No attempts yet1s128 MBJudgeable
Fence RepairSplit one board into N planks of given lengths; each cut costs the length of the piece being cut, so find the minimum total cost.Medium5GreedyHeap+2No attempts yet1s128 MBJudgeable
Anagram GroupsGroup distinct words that are anagrams of each other, then print the five largest groups sorted by size and smallest word.Medium5Hash mapSorting+2No attempts yet1s128 MBJudgeable
Rhinoceros BeetleGiven shared community cards and each player's two hole cards, evaluate every player's best five-card poker hand and print the indices of all winners.Medium5ImplementationSorting+2No attempts yet2s128 MBJudgeable
Peculiar PrimesList every integer in [X, Y] whose prime factors all belong to a given set of at most 10 primes, or print none.Medium5BacktrackingMath+2No attempts yet1s128 MBJudgeable
Building a New DepotGiven the corner posts of an axis-aligned rectilinear polygon (listed in no particular order), reconstruct the polygon and compute its total perimeter.Medium5GeometrySorting+2No attempts yet1s128 MBJudgeable
The Perfect SymmetryGiven a set of distinct integer points, decide whether it has a center of symmetry and, if so, print that center to one decimal place.Medium5Hash mapGeometry+2No attempts yet1s128 MBJudgeable
SnowflakesGiven up to 100,000 snowflakes of six arm lengths each, find whether two are identical under cyclic rotation or reversal.Medium5Hash mapString+2No attempts yet1s128 MBJudgeable
CN TowerGiven angles of landmarks around a rotating restaurant that turns 360 degrees every 72 minutes, find the shortest time window covering all distinct angles.Medium5SortingTwo pointers+2No attempts yet1s128 MBJudgeable
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.Medium5Binary searchSorting+2No attempts yet1s128 MBJudgeable
King Thrór's GoldCount the ways to choose exactly k distinct bar values summing to T, and list all solutions in lexicographic order when there are at most 20.Medium5Dynamic programmingBacktracking+2No attempts yet1s128 MBJudgeable
Go-KartFind the smallest fuel-tank capacity that lets a kart refuel at given stations and travel at least K kilometers.Medium5Binary searchGreedy+1No attempts yet1s1024 MBJudgeable
Sawtooth SequenceGiven N distinct numbers, arrange all of them into a zigzag sequence and output the lexicographically smallest such arrangement.Medium5GreedySorting+2No attempts yet1s1024 MBJudgeable
AnimalsGiven N daily active intervals, some crossing midnight, find whether all overlap at some moment and output the longest common sub-interval.Medium5IntervalsImplementation+2No attempts yet1s1024 MBJudgeable
Railway ConnectionGiven existing rail links and city flows, find the minimum cost to connect all cities, where an edge costs the product of its endpoint flows.Medium5Minimum spanning treeUnion-find+2No attempts yet1s1024 MBJudgeable