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
Bag of BagsProcess bags one by one; keep a bag unless its equality class merges two classes that were already equal, and report the decision for each.Hard8IntervalsUnion-find+2No attempts yet2s256 MBJudgeable
Balanced SequenceReorder n bracket strings to maximize the length of the longest balanced subsequence of their concatenation.Hard8GreedySorting+2No attempts yet1s256 MBJudgeable
Nutella's LifeChoose a subsequence of contests with nondecreasing values, where skipping x contests in a row costs x+1 each, to maximize total fun.Hard8Dynamic programmingSegment tree+1No attempts yet2s512 MBJudgeable
Christmas GarlandGiven a garland of n bulbs with colors, each query flips the state of every bulb of one color, and after each flip you report the number of maximal lit segments.Hard8ArrayImplementation+2No attempts yet2s256 MBJudgeable
Leave Out All The RestGiven two arrays with distinct values, interleave them into one sequence so that its longest increasing subsequence is as long as possible, and output that maximum length.Hard8Dynamic programmingGreedy+2No attempts yet2s512 MBJudgeable
Biggest NumberAfter each of Q point updates to the digits on N cards, report the largest base-D number obtainable by rearranging the cards, modulo 1e9+7.Hard8Segment treeSorting+2No attempts yet0.5s256 MBJudgeable
SeatsGiven n prize values, choose one probability distribution over seats so that a player's expected prize, accounting for random contests at each seat, is maximized.Hard8ProbabilityMath+2No attempts yet1.5s256 MBJudgeable
SchedulingDecide whether n preemptible tasks with release times, deadlines, and processing times can be scheduled on m identical processors within their windows.Hard8GreedySorting+2No attempts yet1s256 MBJudgeable
ScheduleAssign interval tasks to machines so no two overlapping tasks share a machine; minimize the number of machines, then the total working time (earliest start to latest finish) across those machines.Hard8IntervalsGreedy+2No attempts yet2s512 MBJudgeable
Subset SumGiven n integers, output the k smallest sums over all non-empty subsets, in ascending order.Hard8HeapSorting+2No attempts yet5s512 MBJudgeable
GaloisGiven a permutation p, count permutations q with p(q(i)) = q(p(i)) for all i, that have an even number of inversions, modulo 1e9+7.Hard8CombinatoricsMath+2No attempts yet1s512 MBJudgeable
Donut-shaped EnclosurePlace a Chebyshev-distance donut with inner radius L and outer radius R at a lattice center to maximize the total weight of covered points.Hard8GeometryPrefix sum+2No attempts yet3s1024 MBJudgeable
Very New YorkGiven up to 100,000 restaurant points on a grid, answer 100,000 queries counting how many points lie within Manhattan distance d of a query point.Hard8GeometryDivide and conquer+2No attempts yet2s256 MBJudgeable
Median on Binary TreeGiven a heap-shaped binary tree with distinct weights, for every a find the largest a-median, defined as the element at position floor((k-a+1)/2) of a subtree sorted by weight.Hard8TreeDynamic programming+2No attempts yet2s512 MBJudgeable
Hacker Cups and BallsGiven a permutation and range sort operations that go ascending or descending depending on whether l < r, find the value in the middle cup at the end.Hard8Binary searchSegment tree+2No attempts yet3s512 MBJudgeable
PhysicsBalls move on a line with acceleration tied to speed, collide elastically, and each query asks for the k-th smallest velocity at time t.Hard8MathSorting+2No attempts yet1s512 MBJudgeable
Value of the ArrayFor each k from 1 to n, sum over all non-empty subsequences the sum of their min(size, k) largest elements, modulo 998244353.Hard8CombinatoricsSorting+2No attempts yet1s512 MBJudgeable
TrianglesGiven up to 2000 distinct points, count right triangles formed by three of the points whose area falls in the inclusive range [A, B].Hard8GeometryHash map+2No attempts yet10s256 MBJudgeable
Urban BlightGiven points and weighted segments, find a horizontal line whose intersection with the segments maximizes the total weight of segments it touches.Hard8GeometrySorting+2No attempts yet2s1024 MBJudgeable
Voucher PreparationGiven members with distinct skills and names, answer many queries: remove the b highest-skilled members, then partition the best M*a remaining into a teams to maximize the summed product of skills, and output the XOR of the names of all chosen members.Hard8GreedySorting+2No attempts yet2s1024 MBJudgeable
A Game with GrundyFor each i from 0 to N, count integer x positions with L <= x <= R that lie strictly inside at most i of N triangular visibility wedges.Hard8GeometrySorting+2No attempts yet1s512 MBJudgeable
How Many Burgers?Split N burgers with given utilities among three people so that the youngest gets the most he can while not exceeding either senior's total.Hard8Dynamic programmingGreedy+2No attempts yet1s1024 MBJudgeable
Rock ClimbingFind the smallest K such that every K-subset of N rocks contains two rocks A, B with A reachable from B by a strictly upward chain of moves, each move bounded by the max slippery rate.Hard8GraphGreedy+2No attempts yet1s512 MBJudgeable
Cash GapGiven payments with allowed day ranges, decide whether some placement and ordering of the payments forces the balance below zero.Hard8GreedySorting+2No attempts yet1s512 MBJudgeable
Operation <<Permutation>>Given inequalities between positions of an unknown permutation, find the earliest prefix of the conditions that pins down the permutation uniquely, or -1 if never.Hard8GraphTopological sort+2No attempts yet1s512 MBJudgeable
Shushpanchiks and the CinemaGiven an n by n grid with m blocked seats, choose k consecutive free seats in one row minimizing the sum of Manhattan distances to a target seat.Hard8MathIntervals+2No attempts yet2s512 MBJudgeable
String ProcessingDecide whether a recursive split-and-swap program can turn string S into T, and if so output the 2^k - 1 bit program.Hard8Divide and conquerString+2No attempts yet2s512 MBJudgeable
Similar ArraysGiven pairs of positions, decide whether there is an array with all distinct values and an array with a repeated value that agree on every listed comparison, and output both arrays.Hard8GraphDFS+2No attempts yet1s512 MBJudgeable
Pandemic 2On a weighted tree where some vertices start infected and the infection spreads along edges at speed one, find the maximum number of uninfected connected components that ever exist at one moment.Hard8TreeDFS+2No attempts yet1s512 MBJudgeable
Team SelectionSplit N players into two equal teams so the difference between the captains' total scores is minimized, choosing the lexicographically smallest assignment.Hard9Divide and conquerDynamic programming+2No attempts yet2s128 MBJudgeable
Good NumbersGiven a set S of forbidden integers, rank positive integers by how many good intervals (ranges containing only non-S values) contain each one, then print the first n.Hard9CombinatoricsMath+2No attempts yet2s128 MBJudgeable
Goal CelebrationGiven a point inside a field with polygonal obstacles, find the farthest boundary point reachable by a straight segment that avoids the obstacles' interiors.Hard9GeometrySorting+2No attempts yet2s128 MBJudgeable
Robot ArmGiven a rectilinear factory polygon and five candidate fixed points, decide for each whether an L-shaped two-segment robot arm confined to the polygon can reach every interior point.Hard9GeometryIntervals+2No attempts yet5s128 MBJudgeable
Wake Up!Count the distinct points where any two of up to 20,000 line segments intersect, using an efficient computational geometry sweep.Hard9GeometryDivide and conquer+2No attempts yet1s128 MBJudgeable
OrchardGiven up to 2500 non-overlapping colored rectangles, find the maximum area axis-aligned rectangle fully covered by orchards of one fruit type.Hard9GeometryMatrix+2No attempts yet2s64 MBJudgeable
FenceGiven a square field with 4N fence posts and up to 30000 convex polygonal rocks blocking sight lines, count how many posts are visible from a given viewpoint using angular occlusion by polygon silhouettes.Hard9GeometrySorting+1No attempts yet2s128 MBJudgeable
Hyeonju's Pizza ShopGiven jobs with desired completion times and processing times on a single machine, compute the maximum total tip (sum of signed lateness against desired times) after each of many update operations that change a job's parameters, requiring an efficient dynamic scheduling data structure.Hard9GreedySegment tree+1No attempts yet2s128 MBJudgeable
FPSGiven N players and Q candidate additions, count ways to pick K bots with distinct speeds/ranges each dominated by some human, modulo 10009.Hard9CombinatoricsMath+2No attempts yet5s128 MBJudgeable
Chip RoutingAssign each marked point on a square chip a direction toward a side so that drawn segments never cross or pass through other points, minimizing the total segment length.Hard9Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
Hanging HatsSimulate mages hanging triangular hats on a wall, tracking nail visibility and expulsion under coverage rules that require an advanced geometric data structure.Hard9GeometrySegment tree+2No attempts yet3s128 MBJudgeable
Cubic RubeGiven two connected 5x5 height maps of unit cubes, decide whether the pieces can be rotated and translated in 3D to assemble a full 5x5x5 cube.Hard9ImplementationGeometry+2No attempts yet1s128 MBJudgeable
PotholesPlace a straight rope across a rectangular lot without crossing any pothole so the total pothole area is split as evenly as possible, with tie-breaking rules.Hard9GeometrySorting+2No attempts yet1s128 MBJudgeable
ASCII ArtRender triangles with ASCII characters, projecting 3D vertices through a camera onto an S by S screen grid with depth-based visibility.Hard9GeometryImplementation+2No attempts yet1s128 MBJudgeable
TeleportersPlace up to M new teleporters between given endpoints so the forced eastward walk triggers as many teleports as possible.Hard9GreedySorting+2No attempts yet1s128 MBJudgeable
ContactGiven a binary string and a length range [A,B], report the N largest occurrence counts and all patterns achieving each count, with output ordering rules.Hard9StringSorting+2No attempts yet1s128 MBJudgeable
Ballroom LightsGiven point lightbulbs and disjoint circular columns inside a rectangle, compute the total length of the wall perimeter that some lightbulb can reach with a straight, unblocked ray.Hard9GeometryMath+2No attempts yet1s128 MBJudgeable
Not Too Convex HullPartition the nails into B convex polygonal groups, all sharing the origin nail, minimizing the total covered area, with the origin strictly inside the global hull.Hard9Dynamic programmingGeometry+2No attempts yet1s128 MBJudgeable
Largest FenceGiven N grid points with no three collinear, find the size of the largest subset whose points form the vertices of a convex polygon.Hard9GeometryDynamic programming+2No attempts yet2s128 MBJudgeable
LandingGiven up to 100000 integer points, find the largest circle whose boundary passes through at least three points and whose interior contains none, and output R^2 as a reduced fraction.Hard9GeometryCombinatorics+2No attempts yet1s128 MBJudgeable
Move that Mouse AGAINGiven up to 50,000 axis-aligned rectangles in a fixed bottom-to-top stacking order, process 50,000 point clicks, printing the topmost window at each point and moving it to the top of the stack.Hard9Segment treeGeometry+2No attempts yet3s128 MBJudgeable
Checker BoardEach row holds at most one checker per color; players slide their pieces along rows and the one who cannot move loses. Decide whether White wins, Black wins, or the game can run forever.Hard9Game theoryGreedy+2No attempts yet1s128 MBJudgeable
TelecorpPlace one of M module types on any subset of N teleporters, each jump skipping ahead and multiplying speed, to minimize total travel time from 0 to L.Hard9Dynamic programmingGreedy+2No attempts yet1s1024 MBJudgeable
Find the BorderGiven a closed self-intersecting polyline, count the vertices of the border of its interior, the outer boundary enclosing all bounded regions.Hard9GeometryImplementation+2No attempts yet2s128 MBJudgeable
Suffix Array ReconstructionGiven a permutation p, decide whether it is the suffix array of some lowercase string and, if so, output the lexicographically smallest such string.Hard9StringGreedy+2No attempts yet1s512 MBJudgeable
Dextrogyrate CamelFind the longest closed camel route that starts at oasis 1 heading to oasis 2, always turns right by at most 180 degrees at each oasis, never crosses itself, and visits the most distinct oases.Hard9GeometryDynamic programming+2No attempts yet1s512 MBJudgeable
Bus TourChoose a sequence of attractions with strictly increasing construction times maximizing attractiveness collected plus Manhattan travel distance.Hard9Dynamic programmingSorting+2No attempts yet1s128 MBJudgeable
Save the DinosaursFor each vacant point, add it to the existing set and report the area protected by the soldiers (the region where every move gets closer to some soldier).Hard9GeometrySorting+2No attempts yet1s128 MBJudgeable
Wandering Flea TrainersGiven two functional graphs on n labeled nodes, decide whether some vertex relabeling makes the graphs isomorphic, i.e. the fleas' dance is identical.Hard9GraphDFS+2No attempts yet3s128 MBJudgeable
AB-wordsGiven up to 1000 nice ab-words (balanced parentheses words), count the maximum subset of pairwise non-similar words under a recursive similarity relation.Hard9TreeHash map+2No attempts yet1s128 MBJudgeable
TreesFor each tree, find the smallest adjacent-difference sum reachable by either keeping the row or swapping that tree with one other tree.Hard9ArrayMath+2No attempts yet1s128 MBJudgeable
Computational BiologyFor each query length m, find a length-m word whose every cyclic rotation appears in s, maximizing the total count of those rotations in s.Hard9StringSorting+2No attempts yet5s128 MBJudgeable
Army TrainingGiven n points with no three collinear, answer m queries, each a simple clockwise polygon on those points, counting the points strictly inside it.Hard9GeometryCombinatorics+2No attempts yet2s512 MBJudgeable
Reconstructing the Convex PolygonGiven all edges and non-crossing diagonals of a convex polygon with shuffled vertex labels, recover the cyclic boundary order, with vertex 1 first and the smallest possible second vertex.Hard9GraphImplementation+1No attempts yet1s128 MBJudgeable
PeaksFor each query, starting from a peak and using only edges up to a difficulty limit, report the k-th highest reachable peak height or -1.Hard9GraphUnion-find+2No attempts yet2s128 MBJudgeable
The Most Valuable TowerFind the largest sum any single tower can reach by swapping top segments between towers of different heights.Hard9Number theorySorting+2No attempts yet1s512 MBJudgeable
GenomeBuild the lexicographically smallest sequence that is l adjacent swaps from the first genome and k-l swaps from the second.Hard9GreedySegment tree+1No attempts yet1s128 MBJudgeable
Plot of LandGiven up to 3000 pine points and one million query rectangles, report the convex hull area of the points inside each rectangle.Hard9GeometryDivide and conquer+1No attempts yet1s128 MBJudgeable
Thirsty AntsAnts on a line walk at unit speed toward the nearest fallen dew drop, and the task asks for every ant's position when the last drop is drunk.Hard9SimulationSorting+2No attempts yet1s128 MBJudgeable
Aquarium DrainageGiven an orthogonal aquarium floor with holes on its segments, compute the total drain time and the water left behind.Hard9GeometrySorting+2No attempts yet1s128 MBJudgeable
Lonely MountainGiven two orthogonal mountain silhouettes, decide whether any solid casts both and print the largest possible volume modulo 1000000007.Hard9GeometryMath+2No attempts yet2s256 MBJudgeable
Largest and Smallest TriangleGiven n points in the plane, compute the largest and smallest areas among all triangles formed by triples of the points.Hard9GeometrySorting+1No attempts yet6s128 MBJudgeable
Green EnergyPlace towers of given heights on a polygonal terrain to maximize the total length lit by parallel sun rays blocked by terrain and other towers.Hard9GeometryGreedy+1No attempts yet1s128 MBJudgeable
Rail Station RecoveryRecover every station's block number and C or D type from the all-pairs shortest-route distances and station 0's block.Hard9GraphSorting+1No attempts yet3s512 MBJudgeable
ParkingDecide whether axis-aligned cars in a strip of height w can be slid without overlap or rotation from the start layout to the target layout.Hard9GeometryGraph+2No attempts yet3s256 MBJudgeable
Pork barrelFor each query interval [l, h], build the cheapest forest using only roads with costs inside the interval that connects as many city pairs as possible.Hard9Minimum spanning treeDivide and conquer+2No attempts yet30s256 MBJudgeable
Hidden MazeCompute the expected median edge weight over all tree node pairs at odd distance, and print it as a reduced fraction.Hard9Divide and conquerTree+2No attempts yet2s256 MBJudgeable
Same Suffix ArrayCount the strings that differ from the given length N string in exactly one position and keep the same suffix array.Hard9StringString matching+1No attempts yet2s256 MBJudgeable
Radio WatchtowersKeep K of N towers on a line and raise their radio powers so each pair of kept towers can talk, minimizing raise cost minus sale income.Hard9GreedySorting+2No attempts yet1s256 MBJudgeable
CircusFind the smallest starting hold depth on a temporary rope at D that reaches distance M by hopping between ropes within swing range.Hard9Shortest pathSegment tree+1No attempts yet2s512 MBJudgeable
Spin DoctorGiven n points (a_i, b_i) labeled 1 or 0, choose a direction (S, T); with ties broken adversarially, minimize the span covering all label-1 points.Hard9GeometrySorting+2No attempts yet5s512 MBJudgeable
Connect HighwaysGiven two planar connected networks, find the Red-Blue junction pair allowed to be joined by a segment, following a fixed angular tie-breaking rule.Hard9GeometrySorting+2No attempts yet0.4s32 MBJudgeable
Covering postersFor each new axis-aligned rectangle, compute the total area of the given union of rectangles that it covers.Hard9Segment treePrefix sum+2No attempts yet2s1024 MBJudgeable
Archaeological ResearchGiven the surviving shuffled entries of a table of next occurrences for an unknown alphabet size, recover the lexicographically smallest original sequence or report that none exists.Hard9GreedyGraph+2No attempts yet2s512 MBJudgeable
Clique on a LineGiven n points on a line with weights, two points are adjacent when their weights sum to at most their distance; find the largest clique.Hard9Dynamic programmingSorting+2No attempts yet2s512 MBJudgeable
Smallest Unpayable AmountFor each query interval, find the smallest positive amount that cannot be formed as a subset sum of the coins in that interval.Hard9GreedySorting+2No attempts yet4s512 MBJudgeable
PostersCompute the visible area of each of N rectangles pasted in order on the plane, where later rectangles cover earlier ones.Hard9GeometryDivide and conquer+2No attempts yet2s512 MBJudgeable
Laser SensorsGiven N blue points and 2N red points in general position, build the particular non-crossing perfect matching prescribed by the paper's recursive angular-sweep Solve/Attach procedure.Hard9Divide and conquerGeometry+2No attempts yet2s512 MBJudgeable
Counting points inside a circleFor each of M circle queries, count how many of N fixed points lie inside or on the circle, printing the count per query.Hard9GeometryDivide and conquer+2No attempts yet8s512 MBJudgeable
Sequence and Queries 9For each query range [i,j] and value k, count ordered pairs (p,q) from that range with A[p]*B[q] <= k.Hard9Divide and conquerSegment tree+2No attempts yet6s512 MBJudgeable
Where are the bubbles?Given the per-turn swap counts of bubblesort, reconstruct the lexicographically largest permutation that produces exactly those swap counts.Hard9ImplementationGreedy+2No attempts yet2s512 MBJudgeable
Allowed swapsMaintain an array under swaps and union operations, answering whether it can be sorted and counting pairs of clouds whose merge would fix both.Hard9Union-findImplementation+2No attempts yet6s512 MBJudgeable
Appropriate Coordinate MapGiven N points, choose a ring through all of them and endpoints A, B so the two legs are monotone in the projection onto AB, maximizing the smallest gap in that projection.Hard9GeometryGreedy+1No attempts yet5s512 MBJudgeable
Triple treeGenerate triples (a,b,c) satisfying a^2+b^2+c^2 = k(ab+bc+ca)+1 by two sweep operations from (1,k,k+k^2), then greedily print triples whose numbers are all new.Hard9MathNumber theory+2No attempts yet1s512 MBJudgeable
Large Ping Pong TournamentGiven the total points each of 2^N players scored in a knockout ping pong tournament, decide if Dudu, who always wins ties, could have been champion.Hard9GreedySorting+2No attempts yet2s512 MBJudgeable
Robotic Cow HerdEach robot picks one model per location, and all K robots must differ somewhere; find the minimum total cost of K distinct robots.Hard9HeapGreedy+2No attempts yet2s512 MBJudgeable
Soldiers (Large)Two players alternately pick soldiers, each new pick must beat all previous picks in attack or in defense; decide if the first player can end up with strictly more picks.Hard9Game theoryDynamic programming+1No attempts yet5s512 MBJudgeable
Clash Royale (Large)Pick 8 of N cards and spend at most M coins on upgrades to maximize the total attack power of the chosen deck.Hard9Dynamic programmingGreedy+1No attempts yet20s512 MBJudgeable
Rides 2Each day one child grows by 1 or 2, and we must report how many of Q fixed child-pair and ride triples become valid that day.Hard9Segment treeSorting+2No attempts yet2s256 MBJudgeable
Distinct Substring QueriesMaintain a string under push-back and pop-front operations, reporting the number of distinct substrings after each of up to a million queries.Hard9StringString matching+2No attempts yet2s512 MBJudgeable
Rolling the BottleGiven a convex polygon as a bottle base and a water volume, find the minimum and maximum number of sides of the water region as the bottle rolls.Hard9GeometrySorting+2No attempts yet2.5s512 MBJudgeable