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,732 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
TribesRepeatedly merge axis-aligned rectangles whose overlap has positive area into their bounding box, then print the remaining boxes in lexicographic order.Hard8Union-findSegment tree+2No attempts yet3s1024 MBJudgeable
FertilizingEach day the C_i shortest of N trees grow by the day number and the K_i-th shortest height is recorded; report the sum over all days.Hard8Segment treeSorting+1No attempts yet3s256 MBJudgeable
How Does Your Garden Grow?Place up to 50 one-metre plants on a 10 cm grid so the squared gap between each plant water need and the sprinkler water its interval collects is minimal.Hard8Dynamic programmingMath+1No attempts yet30s256 MBJudgeable
Line SweepFind the tallest vertical broom that still reaches every empty cell by sliding sideways, then the fewest sideways sweeps that clean them all.Hard8GreedyIntervals+2No attempts yet10s256 MBJudgeable
The ImpPick boxes in some order while an adversary voids up to k of them, and maximize the kept item value minus all purchase costs under optimal play.Hard8Game theoryDynamic programming+1No attempts yet15s256 MBJudgeable
Enchanted ForestGiven initial heights and growth rates on an N by N grid, find the largest edge-connected group sharing one height at some present or future real time.Hard8Union-findSorting+1No attempts yet2s128 MBJudgeable
Truck EncountersCount how many times each queried pair of trucks, moving at equal speed along zigzag city routes, occupy the same position.Hard8IntervalsSorting+1No attempts yet3s64 MBJudgeable
Cactus GeneratorParse the SCGL definition, build the cactus it describes with merged vertices renumbered, and print the counts, path cover number, and sorted edges.Hard8GraphUnion-find+2No attempts yet1s256 MBJudgeable
The j-th NumberAfter copying each insert value into every array of its interval, each query asks for the j-th smallest value collected from an interval of arrays.Hard8Binary searchSegment tree+2No attempts yet10s512 MBJudgeable
Floating IslandsFind the cheapest connected bridge network where each bridge costs the position difference and each island has a degree limit, or report -1 when impossible.Hard8Dynamic programmingMinimum spanning tree+1No attempts yet8s512 MBJudgeable
Revenge of the ants 2Labeled ants walk both ways on a circular rail and bounce on collision; compute when each ant is back at its start with its initial direction.Hard8String matchingSorting+2No attempts yet5s256 MBJudgeable
Maximize the matrix sumReorder entries by rotating rows and columns and flipping row and column signs to maximize the sum of all cells.Hard8MathGreedy+2No attempts yet2s256 MBJudgeable
Forming TeamsFor each planned day, decide whether students with accepted size ranges can fill all requested teams of the given sizes.Hard8GreedyIntervals+2No attempts yet4s512 MBJudgeable
Sorting 2Choose one swap per round after the fixed rival swap to sort the permutation in the fewest rounds, with the lexicographically smallest choice list on ties.Hard8BFSShortest path+1No attempts yet1s512 MBJudgeable
ExchangeCount the swaps performed by running the first M passes of selection sort on each array.Hard8Segment treeSorting+1No attempts yet1s256 MBJudgeable
Reducing Network DiameterPay per unit of reduction on tree edge weights so the longest path between any two nodes is at most D at minimum total cost.Hard8GreedyTree+2No attempts yet2s256 MBJudgeable
HiveEach rabbit walks a right-or-down path from the top-left cell to the bottom-right cell, and the goal is the fewest paths covering every flower.Hard8GraphCombinatorics+2No attempts yet1s256 MBJudgeable
Ants in a CorridorAnts join a corridor over time and bounce off each other and both walls, and each query asks for the position of one numbered ant.Hard8MathSortingNo attempts yet3s512 MBJudgeable
Pyramid BaseFind the side length of the largest axis-aligned square on a grid that avoids all given rectangular obstacles.Hard8Binary searchGeometry+2No attempts yet5s128 MBJudgeable
Cow ConfinementEach cow moves only down or right across a large grid and cannot cross rectangular fences, and the task asks how many flowers each cow can reach.Hard8Segment treeSorting+1No attempts yet10s512 MBJudgeable
Export EstimateFor each threshold query, count the vertices and edges left after deleting low-priority streets and contracting degree-two vertices in index order.Hard8GraphUnion-find+1No attempts yet4s512 MBJudgeable
Min-Max Distance GameStarting from the given first player, both sides alternately remove one stone until two remain, with Alice maximizing and Bob minimizing the final distance.Hard8Game theoryGreedy+1No attempts yet1s256 MBJudgeable
Niya's HappinessTrack insertions and deletions in a banknote multiset and report after each update whether every amount up to the total is payable exactly.Hard8Segment treeSorting+1No attempts yet3s512 MBJudgeable
Queue of SoldiersCount distinct lineups of soldiers with given heights where exactly K soldiers have a strictly shorter soldier ahead of them.Hard8CombinatoricsDynamic programming+1No attempts yet5s256 MBJudgeable
Stop Making SenseFor each input point in turn, remove it and report the area of the smallest convex polygon enclosing the rest.Hard8GeometrySorting+1No attempts yet1s256 MBJudgeable
SubstringsOrder all given strings as the consecutive length-L windows of one string of length L+N-1 and print the lexicographically smallest such string.Hard8GraphDFS+2No attempts yet2s256 MBJudgeable
Subsequence HashesPrint the polynomial hashes of the K lexicographically smallest non-empty subsequences of the given array.Hard8HeapSorting+1No attempts yet1s256 MBJudgeable
Counting palindromesCount the palindromic substrings fully contained in each query interval of a lowercase string.Hard8String matchingSegment tree+2No attempts yet2s64 MBJudgeable
K-th smallest weight on a tree pathAnswer each query with the K-th smallest vertex weight on the path between two vertices in a tree.Hard8Segment treeTree+1No attempts yet1.5s512 MBJudgeable
Fortune Telling 2N two-sided cards start showing A_i and each threshold T_j flips every card whose visible number is at most T_j; compute the final visible sum.Hard8Segment treeSorting+1No attempts yet2s256 MBJudgeable
Fairland (Large)Keep the largest rooted connected subtree containing the CEO so all kept salaries fit within a range of width D.Hard8TreeSliding window+2No attempts yet10s512 MBJudgeable
Log Set (Large)Recover the original integer multiset from the frequency table of all its subset sums, breaking ties by lexicographic order.Hard8GreedySorting+1No attempts yet5s512 MBJudgeable
Hiking DeerChoose speeds, including full stops, for one clockwise loop of a circular trail to minimize meetings with hikers who walk at constant speeds.Hard8MathSorting+1No attempts yet5s512 MBJudgeable
ARAM (Large)Decide when to spend reroll currency on random champions to maximize the long-run win rate over many games.Hard8Dynamic programmingProbability+2No attempts yet120s512 MBJudgeable
Ticket SwappingPassengers riding one direction on a line pay a decreasing per-stop fare and may swap entry cards where trips overlap, so compute the maximum total fare loss.Hard8GreedySorting+2No attempts yet5s512 MBJudgeable
The Great Wall (Large)Count how many moving interval attacks pierce a wall that rises after each success to the strength that would have stopped it.Hard8Segment treeIntervals+1No attempts yet15s512 MBJudgeable
Upstairs and DownstairsKonstantin chooses and orders at least K activities from limited copies to minimize the chance Ilia wakes after falling asleep.Hard8ProbabilityDynamic programming+2No attempts yet5s512 MBJudgeable
Upstairs and DownstairsKonstantin must order at least K activities with capped repeats to minimize the chance Ilia falls asleep and later wakes.Hard8ProbabilityGreedy+1No attempts yet100s512 MBJudgeable
Travel Plan (Large)Visit every planet on a line exactly once and return to Earth, maximizing total travel distance without exceeding the fuel limit.Hard8Dynamic programmingSorting+1No attempts yet5s512 MBJudgeable
Minimum Triangle PerimeterGiven up to 10000 points, find three whose triangle has the smallest total perimeter, with collinear triples allowed.Hard8GeometryDivide and conquer+1No attempts yet5s512 MBJudgeable
Minimum Triangle PerimeterGiven up to a million integer points, pick three that form the triangle of smallest perimeter and report that perimeter.Hard8GeometryDivide and conquer+1No attempts yet90s512 MBJudgeable
Stock ChartsPartition n stock price sequences into the fewest groups so that within each group no two polylines cross or touch at any time point.Hard8Dynamic programmingGreedy+1No attempts yet5s512 MBJudgeable
BoatCount subsets of schools with an assigned boat count in [a_i, b_i], strictly increasing in school order, excluding the empty setup, modulo 1e9+7.Hard8Dynamic programmingCombinatorics+2No attempts yet2s512 MBJudgeable
Relay SignalCount boats reachable within one relay hop from boat 1, where visibility means the connecting segment never enters the convex island interior; every coordinate is a lattice point.Hard8GeometrySorting+2No attempts yet2s512 MBJudgeable
Wall RepairA robot on a line must visit every point; each point's repair cost grows linearly with the time it waits, so find the visiting order of minimum total cost.Hard8Dynamic programmingIntervals+2No attempts yet1s1024 MBJudgeable
First Pair to MeetGiven people at vertices of a weighted undirected graph, find the minimum over all pairs of half their shortest-path distance; roads are traversed at 10 km/h and the time prints in minutes.Hard8GraphShortest path+2No attempts yet2s512 MBJudgeable
Maximum substring costGiven a string T, find the maximum of length times number of occurrences over all substrings S of T.Hard8StringSorting+2No attempts yet2s512 MBJudgeable
Hongjun's IntersectionSum the lengths of the intersections of all k-subsets of given segments, modulo 1e9+7.Hard8SortingCombinatorics+1No attempts yet2s512 MBJudgeable
Run and Swim RaceGiven each runner's running and swimming speeds, find every participant who can finish first for some positive choice of the leg lengths R and S.Hard8GeometrySorting+2No attempts yet2s512 MBJudgeable
Fewest letters for a suffix arrayGiven a permutation that is a suffix array, find the minimum number of distinct letters needed for a string that realizes exactly this suffix array.Hard8StringGreedy+2No attempts yet2s512 MBJudgeable
Minho's WishFor each of Q range queries on an array, count how many distinct values occur at least three times within the queried index range.Hard8Segment treePrefix sum+2No attempts yet2s512 MBJudgeable
ChaosStarting from n numbers, repeatedly replace three numbers a, b, c by two copies of floor((sum of a chosen pair)/2); find the maximum equal value that can remain.Hard8GreedyMath+2No attempts yet2s512 MBJudgeable
Jewel ThiefFor each knapsack capacity 1 through k, compute the maximum total value of a subset of n jewels whose sizes sum to at most the capacity.Hard8Dynamic programmingGreedy+1No attempts yet10s512 MBJudgeable
FenceGiven points on grid corners, find the shortest closed fence along cell edges and diagonals that encloses all of them, output as a + b*sqrt(2).Hard8GeometrySorting+1No attempts yet2s512 MBJudgeable
Optimal TournamentPlace N contestants with given strengths at the leaves of a knockout bracket of height at most K so that the total strength difference over all matches is minimized.Hard8Dynamic programmingSorting+2No attempts yet5s512 MBJudgeable
Scorpion Test for Permutation GraphsAfter each swap in a permutation A, decide whether the permutation graph (edges between crossing chords) is scorpion-like.Hard8GraphSorting+2No attempts yet1s256 MBJudgeable
Counting Bow TiesCount 4-cycles in a bipartite graph defined by M rectangles over vertex ranges, with N up to 1e9.Hard8GeometryCombinatorics+2No attempts yet2s256 MBJudgeable
King of ChairsArrange N ladies, each sitting or standing with probability 1/2, to maximize the expected number of ordered pairs where the person behind is strictly taller.Hard8SortingGreedy+2No attempts yet1s32 MBJudgeable
PasswordGiven a length-N string, collect all distinct substrings meeting four counts (length, digits, specials, uppercase), sort them lexicographically, and print the middle one.Hard8StringSorting+2No attempts yet4s512 MBJudgeable
Minimum Diameter SumSplit a set of n planar points into two nonempty groups so that the sum of the two group diameters is minimized, and print the value.Hard8GeometryBinary search+2No attempts yet1s512 MBJudgeable
Meteor ShowerCount the convex polygons that are completely hidden from the origin by other polygons, since every ray stops at the first one it hits.Hard8GeometrySorting+1No attempts yet1s512 MBJudgeable
XOR SequenceChoose B in [0, N-1] to XOR every element of A, then find the maximum possible count of index pairs i < j with C_i < C_j.Hard8Divide and conquerBit manipulation+2No attempts yet2s512 MBJudgeable
Rock BandEach of M members ranks all S songs; a set list is valid if every member plays all songs they rank above any chosen song. Find a shortest valid set list.Hard8GreedySorting+2No attempts yet4s512 MBJudgeable
The Longest Welded SwordSelect and order all plates so that widths strictly decrease, orienting each plate to maximize the total contributed length sum.Hard8GreedySorting+2No attempts yet7s512 MBJudgeable
Counting Similar TreesGroup labeled trees that are isomorphic under a bijection preserving edge label differences, and report each group size.Hard8TreeHash map+2No attempts yet2s512 MBJudgeable
Sorting GameApply K sets of operations, each sorting a prefix of length A ascending then a prefix of length B descending, and print the final sequence.Hard8SortingImplementation+2No attempts yet1s128 MBJudgeable
Inversions of a simple path sequenceGiven a connected unimodal (unicyclic) graph, find a minimum inversion count over simple paths visiting at least K vertices, or -1 if none exist.Hard8GraphDynamic programming+2No attempts yet2s512 MBJudgeable
Counting ear shapesCount quadruples of red points and pairs of blue points forming an ear shape with angle and containment conditions.Hard8GeometryBrute force+2No attempts yet2s512 MBJudgeable
Substitution Cipher KeyGiven N distinct words and a target permutation, find the lexicographically smallest substitution cipher key that sorts the encrypted words into that order, or report none.Hard8GreedySorting+2No attempts yet1s64 MBJudgeable
KingN elves each target a dwarf; elves enter one at a time and slide clockwise to the next free spot. Choose the entry order to maximize elven wins.Hard8GreedySorting+2No attempts yet2s128 MBJudgeable
Romeo and JulietCompute each person's maximum guilt-to-Juliet and pain-to-Romeo transfer product, weight every event, then remove up to k events to minimize the total.Hard8GraphShortest path+2No attempts yet2s512 MBJudgeable
Distance to the nearest pointFor each of N points, report the Manhattan distance to the nearest other point.Hard8GeometryDivide and conquer+1No attempts yet2s512 MBJudgeable
Sequence and Queries 1Given a static sequence, answer M queries counting how many values in range A[i..j] are greater than k.Hard8Segment treeSorting+2No attempts yet1s512 MBJudgeable
Sequence and Queries 3Given a static sequence, answer queries (decoded with the previous answer via XOR) counting how many elements in a subarray exceed k.Hard8Segment treeBinary search+1No attempts yet1s512 MBJudgeable
Counting close pairs in a rangeGiven a sequence and K, each query asks how many index pairs inside a subarray have value difference at most K.Hard8Divide and conquerPrefix sum+2No attempts yet3s512 MBJudgeable
RoomGiven points on the edges of an unknown orthogonal monotone polygon with edge orientations, reconstruct it and output its perimeter or -1 if impossible.Hard8GeometrySorting+2No attempts yet2s512 MBJudgeable
Olympic Gold AthletesEach athlete's skill and fatigue change linearly in time; count those who are the unique max-skill and unique min-fatigue athlete at some time t >= 0.Hard8GeometryBinary search+2No attempts yet1s512 MBJudgeable
Rectangular PlazaCount axis-aligned rectangles whose corners include two given lamps and whose interior contains no other lamp, given all X and Y coordinates are distinct.Hard8GeometrySorting+1No attempts yet1s512 MBJudgeable
BalloonGiven N disjoint ceiling segments, trace each vertically rising balloon as it sticks to horizontal segments or slides to the higher endpoint of tilted ones, and report the final resting point or escape x coordinate.Hard8GeometrySorting+2No attempts yet2s512 MBJudgeable
Tire PatchesOn a circular tire, cover all hole positions with the minimum total length of uncut patches of two given lengths and return that total length.Hard8Dynamic programmingArray+2No attempts yet2s512 MBJudgeable
EnclosureGiven k controlled points forming a convex hull, add one of the remaining points to maximize the hull area, and print the resulting area to one decimal.Hard8GeometryGreedy+2No attempts yet2s512 MBJudgeable
Maximum Tent VolumeAssign n poles of given heights to a central hole and n-1 fixed holes around it to maximize the total volume of the resulting triangles.Hard8GeometryDynamic programming+2No attempts yet2s512 MBJudgeable
Krypton StadiumsGiven n intervals where interval i contains point i, classify the layout as Great, Acceptable, or Bad based on whether pairs of cities are co-hosted by a nesting or shared stadium.Hard8IntervalsGreedy+2No attempts yet10s512 MBJudgeable
Rotation EstimationGiven two unordered point sets related by a rotation plus translation, find the smallest counterclockwise rotation angle in [0, 2pi) that maps the first set onto the second.Hard8GeometrySorting+2No attempts yet8s512 MBJudgeable
Ramen Shop SeatingSimulate a ramen shop with N counters of fixed seats where arriving groups pick the best free block under a preference rule and may leave if they wait too long; report average customer satisfaction.Hard8SimulationImplementation+2No attempts yet8s512 MBJudgeable
Online Quiz SystemGiven per-player delays and each player's answer timing, simulate the polling protocol and report bytes sent and received by the server and each player.Hard8SimulationImplementation+2No attempts yet8s512 MBJudgeable
Three SquaresGiven N integer points, find the smallest side length L so that three equal axis-parallel squares of side L can cover every point.Hard8Binary searchSorting+2No attempts yet1s256 MBJudgeable
Emission SpectrumMaintain an integer array under adjacent swaps and answer k-th smallest value queries over subarrays online.Hard8Binary searchDivide and conquer+2No attempts yet2s512 MBJudgeable
Washroom Satisfaction IndexAfter each point update to guest washroom times, compute the minimum sum over assignments of wait-plus-service times to W washrooms, where each washroom serves a subset in some order.Hard8GreedySorting+2No attempts yet10s512 MBJudgeable
ACM TaxFor each query path in a weighted tree, output the median edge length, rounded to one decimal.Hard8TreeBinary search+2No attempts yet5s512 MBJudgeable
Sequence and Queries 14For each query on a subarray, take the distinct values, sort them, and report the k-th smallest, with each query depending on the previous answer.Hard8ArraySorting+2No attempts yet5s1536 MBJudgeable
Gotta Nudge 'Em AllChoose one 30-minute window for a double-XP bonus, catch every Nudgemon already logged, and maximize XP from evolutions inside that window.Hard8GreedySliding window+1No attempts yet3s512 MBJudgeable
Contest StrategySum the contest penalty over all n! read orders, where after reading k problems you always solve the read-but-unsolved problem with the smallest solving time.Hard8CombinatoricsGreedy+2No attempts yet2s512 MBJudgeable
Demilitarized ZoneFor each protected point, count how many starting mines eventually trigger a blast covering it, given chain reactions over intervals.Hard8IntervalsSorting+2No attempts yet3s256 MBJudgeable
Solar FlightFor a line segment query, find the maximum total intercept-weight above a given ray over all x in a length-K window.Hard8GeometrySorting+2No attempts yet15s512 MBJudgeable
Data StructureGiven M required cells in a triangular pyramid with N up to 1e9, find the minimum number of filled cells so that every filled cell has both supporting cells below it filled.Hard8GreedySorting+2No attempts yet2s512 MBJudgeable
Zombie ApocalypseGiven up to 2000 zombie cells on an N by M grid with Chebyshev distance spreading, count how many cells end up at level Q.Hard8GeometrySorting+2No attempts yet2s512 MBJudgeable
Broadcast Tower OffersFor each offered tower height, find the best position along a row of buildings and report how many buildings to its west can receive its westward signal.Hard8StackSorting+2No attempts yet2s512 MBJudgeable
K representatives on a lineFor each K from 1 to N, place K real points on a line to minimize the total distance to all given points.Hard8Dynamic programmingDivide and conquer+2No attempts yet2s512 MBJudgeable
Quadrilateral blanketGiven N points and an area limit L, pick four points forming a simple quadrilateral with area at most L, maximizing that area.Hard8GeometryBrute force+2No attempts yet5s128 MBJudgeable