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 results389 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Probability ExperimentCount the triples of given points on a circle that form an acute triangle.Medium6Two pointersCombinatorics+1No attempts yet1s256 MBJudgeable
Magical, Marvelous TourArnar picks a contiguous segment, Solveig claims the largest of the three parts it creates, and Arnar keeps the rest.Medium6Prefix sumTwo pointersNo attempts yet5s512 MBJudgeable
Deceitful War (Large)Given both players' block weights, compute Naomi's optimal scores under honest play and under bluffed announcements.Medium6GreedySorting+1No attempts yet5s512 MBJudgeable
Minimum weight spread for strong connectivityPick a strongly connected subgraph of a complete directed graph so the chosen edges' weight range is as small as possible.Medium6GraphSorting+2No attempts yet2s512 MBJudgeable
Fun box packingGiven N box sizes, nest a box inside another when the outer size is at least twice the inner, each box holds at most one, and minimize the number of visible (unnested) boxes.Medium6GreedySorting+2No attempts yet2s512 MBJudgeable
RailroadGiven n intervals with distinct endpoint positions, find the maximum number of intervals fully contained in some segment of fixed length d.Medium6SortingSliding window+2No attempts yet1s512 MBJudgeable
Why Did the Cow Cross the Road 4Match chickens, each available at a single time, to cows whose interval covers that time, so that as many cows as possible get help.Medium6GreedySorting+2No attempts yet2s512 MBJudgeable
Paired UpPair up M cows with given milk outputs to minimize the maximum sum in any pair, where each pair's time is A+B. Input gives counts and output values in compressed form.Medium6GreedyTwo pointers+2No attempts yet2s512 MBJudgeable
A rain of shooting starsPlace an axis-aligned square of side L to cover as many of K points as possible, counting points on any edge as covered.Medium6ArraySorting+2No attempts yet2s256 MBJudgeable
Sickly YunhoGiven a string of B, L, D doses, remove from either end in the fixed order B, L, D, B, L, D... and find the most doses removable before the required dose is missing from both ends.Medium6Dynamic programmingArray+2No attempts yet1s512 MBJudgeable
The Longest FenceGiven up to 10^6 board lengths (each at most 2000), pair them into boards of equal sum and report the largest possible number of boards plus how many sums reach it.Medium6ArrayTwo pointers+2No attempts yet2s512 MBJudgeable
Closest PairBoth point sets lie on horizontal lines; find the Manhattan distance of the closest P-Q pair and count how many distinct pairs achieve it.Medium6SortingTwo pointers+1No attempts yet1.5s512 MBJudgeable
Bumper to bumper trafficTwo cars 4.4 m long start stopped on a line and alternate between stopping and driving at 1 m/s at given times; decide whether they ever touch, giving the first contact second rounded up.Medium6ImplementationSimulation+2No attempts yet4s512 MBJudgeable
Fashion ShowGiven a legal partial placement of +, x, and o models on an N by N grid, add or upgrade models to maximize style points under the row/column and diagonal rules.Medium6GraphTwo pointers+2No attempts yet5s512 MBJudgeable
Ratatouille (Large)Given amounts of each ingredient, pair packages into kits so that each package in a kit is within 90 to 110 percent of the recipe amount for the kit's integer serving count, maximizing kits.Medium6GreedyTwo pointers+1No attempts yet5s512 MBJudgeable
Orderly ClassGiven two equal-length strings A and B, count the intervals in A such that reversing that interval turns A into B.Medium6StringTwo pointers+2No attempts yet2s512 MBJudgeable
Club Room RepairsAssign each club at most one room and each room at most one club, where Jongbin covers max(0, cost - budget) up to X total; maximize clubs housed.Medium6GreedySorting+2No attempts yet2s512 MBJudgeable
Haybale FeastPick a contiguous block whose flavor sums to at least M while minimizing the block's maximum spiciness.Medium6Two pointersSliding window+2No attempts yet2s512 MBJudgeable
An Unfair PuzzleGiven two permutations of 1..n, decide whether cyclic rotations and reversals can turn the first into the second, printing good puzzle or bad puzzle.Medium6StringString matching+2No attempts yet2s256 MBJudgeable
Cow Rental ServiceChoose for each cow whether to milk it or rent it, matching milk to stores with limited quantity and price, to maximize total cents.Medium6GreedySorting+2No attempts yet2s512 MBJudgeable
Junpyo's PebblesFind the longest contiguous segment containing at most B black pebbles and at least W white pebbles.Medium6Two pointersSliding window+1No attempts yet1s512 MBJudgeable
Skyscraper MinatoHarukasFor each budget b, find the longest run of consecutive positive integers summing to b and print its first floor and length.Medium6MathTwo pointers+2No attempts yet2s512 MBJudgeable
MeetingsEach person occupies an interval [Si, Ei]; pair up people whose intervals overlap into disjoint pairs and maximize the number of pairs.Medium6GreedySorting+2No attempts yet1s1024 MBJudgeable
StarwarsGiven human systems, bases, and directed labeled wormholes, decide whether a nonhuman start yields a certificate sequence matching one produced by some human start reaching any base.Medium6GraphBFS+2No attempts yet1s512 MBJudgeable
Random Index VectorsMerge two sparse signed index lists to output their element-wise sum, product, and each list rotated left by k with wraparound.Medium6Two pointersHash map+2No attempts yet2s512 MBJudgeable
Substring PermutationGiven strings S and P, decide whether some permutation of P is a substring of some permutation of S.Medium6Hash mapTwo pointers+1No attempts yet1s512 MBJudgeable
JackRabbit SlimGiven sorted distinct carrot positions on a line, Slim repeatedly jumps to the nearest remaining carrot, breaking ties to the right; find the sum of total distances over all possible starting carrots.Medium6Dynamic programmingArray+2No attempts yet2s512 MBJudgeable
Rainbow BeadsFind the longest contiguous substring of a string over R, B, V that has no equal adjacent pair under any of the three color-blind views.Medium6Two pointersSliding window+2No attempts yet1s1024 MBJudgeable
KingsGiven n kings on an n by n board, find the minimum total moves to shift every king onto the main diagonal, where a move shifts one king one cell horizontally or vertically.Medium6Two pointersGreedy+2No attempts yet1s512 MBJudgeable
Count SquaresGiven coordinates of h horizontal and v vertical lines, count how many axis-aligned squares have all four sides drawn by those lines.Medium6ArrayHash map+2No attempts yet2s512 MBJudgeable
AlehouseGiven n closed time intervals on a weekly circle, pick one interval of length at most k that intersects as many given intervals as possible.Medium6IntervalsSliding window+2No attempts yet1s512 MBJudgeable
ASLRDRReorder a string with adjacent swaps so it becomes a palindrome, reporting the minimum number of swaps or Impossible.Medium6GreedyTwo pointers+2No attempts yet2s512 MBJudgeable
JJOOII 2Given a string of J, O, I and a level K, delete characters from the ends or middle to obtain K J's then K O's then K I's, minimizing middle deletions.Medium6GreedyTwo pointers+2No attempts yet2s512 MBJudgeable
Balls of BumaGiven a row of colored balls, count the color and insertion position pairs that make the chain reaction remove every ball.Medium6StringImplementation+2No attempts yet3s512 MBJudgeable
Three ArraysGiven three sorted arrays and a distance d, count triples of elements (one from each array) whose pairwise differences all stay within d.Medium6Two pointersSorting+2No attempts yet2s256 MBJudgeable
Currency ExchangeGiven n tablet values and an integer rate p, find two distinct indices i and j so that the ratio c_i / c_j is as close to p as possible.Medium6ArrayBinary search+2No attempts yet2s512 MBJudgeable
Running CourseGiven up to 100,000 2D points, compute the squared distance between the farthest pair of points.Medium7GeometrySorting+2No attempts yet2s256 MBJudgeable
Four SubstringsGiven a string and four of its substrings, pick one occurrence of each so that the union of the covered positions has the fewest and the most distinct characters.Medium7String matchingIntervals+2No attempts yet2s512 MBJudgeable
Once Opened, You Can't StopChoose one integer per flavor within its given range so the sum of absolute changes between consecutive picks is minimized, and output the values.Medium7Dynamic programmingGreedy+2No attempts yet2s128 MBJudgeable
Point SelectionGiven weighted 2D points, find a placement of a fixed-size axis-aligned rectangle maximizing the difference between the maximum and minimum weights of points it covers.Medium7Sliding windowSorting+1No attempts yet2s128 MBJudgeable
Jewel HeistGiven colored points, find the maximum number of points coverable by a horizontal-span rectangle extending down to minus infinity that avoids containing all k colors.Medium7Two pointersSorting+1No attempts yet5s128 MBJudgeable
Choosing NumbersGiven a sequence, delete exactly K elements so that the sum of the largest gap and the smallest adjacent gap among the remaining elements is minimized.Medium7SortingSliding window+2No attempts yet1s256 MBJudgeable
Largest SquareGiven an N by N grid with W bad cells listed explicitly, find the largest axis-aligned square containing at most L bad cells.Medium7Binary searchPrefix sum+2No attempts yet2s128 MBJudgeable
TransmittersGiven a fixed center, a radius, and up to 150 points, find the largest number of points that fit inside some semicircular half-disk at any rotation.Medium7GeometryTwo pointers+2No attempts yet1s128 MBJudgeable
Circle and PointsGiven up to 300 points, find the maximum number coverable by one radius-1 circle, using a sweep over candidate centers.Medium7GeometryBrute force+2No attempts yet1s128 MBJudgeable
Amphiphilic Carbon MoleculesPlace a single line to maximize the number of particles that dissolve: hydrophilic on the water side plus hydrophobic on the acetone side, counting any particle on the line.Medium7GeometryTwo pointers+2No attempts yet5s128 MBJudgeable
Run, IOI TrainDiscard a prefix from each of two I/O strings, then interleave the remaining fronts to build the longest alternating string that starts and ends with I.Medium7Dynamic programmingTwo pointers+2No attempts yet1s128 MBJudgeable
Probability Through ExperimentGiven n points on a circle by angle, count how many triples form an acute triangle.Medium7GeometryTwo pointers+2No attempts yet2s128 MBJudgeable
Rice HubGiven sorted field positions on a line and a budget B, choose an integer hub position maximizing how many fields can be reached within total transport cost B.Medium7Two pointersPrefix sum+2No attempts yet1s256 MBJudgeable
PhotoGiven N cows in a line and K unfriendly pairs that cannot share a photo, find the minimum number of consecutive-range photos covering every cow.Medium7GreedyIntervals+2No attempts yet1s128 MBJudgeable
Covering the CorralGiven arcs of given start and length on a circle of circumference C, find the fewest arcs whose union covers the whole circle.Medium7GreedySorting+2No attempts yet1s128 MBJudgeable
RestaurantSplit a sequence of N foods into consecutive groups, where a group costs the square of its number of distinct foods, and minimize the total cost.Medium7Dynamic programmingDivide and conquer+2No attempts yet1s128 MBJudgeable
CN Tower 2Choose a starting camera orientation so a rotating restaurant brings every landmark's bearing past the camera; minimize total time including flash recharge and the final recharge.Medium7SortingGreedy+2No attempts yet1s128 MBJudgeable
TripsMatch group sizes to trip intervals so that each interval gets at most one group and the number of matched intervals is maximized.Medium7GreedySorting+2No attempts yet1s128 MBJudgeable
Longest Common Increasing SubsequenceGiven two integer sequences, find the length of the longest common increasing subsequence of both.Medium7Dynamic programmingArray+2No attempts yet1s256 MBJudgeable
Knights of the Round TableGiven chairs at rational angles on a circle of radius n, find the maximum straight-line distance between any two chairs, rounded to two decimals.Medium7GeometryTwo pointers+2No attempts yet2s128 MBJudgeable
Beach cutGiven a polyline shoreline, pick two vertices at distance at most L and connect them below the shore to maximize the enclosed beach area.Medium7GeometryTwo pointers+1No attempts yet1s128 MBJudgeable
GoldmineGiven n points and an axis-aligned rectangle of fixed width s and height w, find the maximum number of points the rectangle can cover, borders included.Medium7SortingTwo pointers+2No attempts yet3s512 MBJudgeable
Where to Build a Brewery?On a ring of cities with given edge lengths and demands, pick the city minimizing total demand-weighted shortest-path distance around the ring.Medium7Prefix sumTwo pointers+2No attempts yet3s512 MBJudgeable
The Number of Symmetrical ChoicesGiven two word sequences of length n, count how many of the 2^n ways of picking one word per index produce a palindrome when concatenated.Medium7Dynamic programmingString+2No attempts yet1s128 MBJudgeable
BlocksGiven pile heights, for each k find the longest run of consecutive piles that can be raised to height at least k by moving top blocks between neighbors while staying above k.Medium7GreedyTwo pointers+1No attempts yet3s512 MBJudgeable
LollipopFor each query k, find the lexicographically smallest contiguous segment of a T/W string whose weight (T=2, W=1) equals k, or print NIE if none exists.Medium7Prefix sumTwo pointers+2No attempts yet1s128 MBJudgeable
SticksFrom sticks grouped by colour, find three sticks of pairwise different colours that form a non-degenerate triangle and maximise the perimeter.Medium7SortingGreedy+1No attempts yet1s128 MBJudgeable
Farmer's FieldCount placements of a c-by-d or d-by-c rectangle fully inside a field whose every row is one contiguous segment.Medium7Sliding windowStack+2No attempts yet1s128 MBJudgeable
LinesFind the line through a fixed point P that minimizes the maximum distance from P's line to any of n given points, and print that minimum distance rounded down to three decimals.Medium7GeometryBinary search+2No attempts yet1s128 MBJudgeable
Cake PieceFind the k-th largest piece area after cutting a rectangle with n cuts in each direction.Medium7Binary searchSorting+2No attempts yet1s512 MBJudgeable
PointsCount triangles formed by white points that have no black point strictly inside them.Medium7GeometryCombinatorics+2No attempts yet1s128 MBJudgeable
PatternCount the positions in the text where the pattern matches when every letter is repeated the same number of times.Medium7String matchingTwo pointers+1No attempts yet1s128 MBJudgeable
Almost LCSGiven two binary strings up to 100000 characters, find the longest 0^a1^b or 1^a0^b string that is a subsequence of both.Medium7Prefix sumTwo pointers+1No attempts yet1s128 MBJudgeable
SquaresChoose one point from each axis-parallel square to maximize the farthest pair distance, and print that maximum squared.Medium7GeometrySorting+1No attempts yet1s128 MBJudgeable
TokensFor each token with given length and lookahead, compute how far back its text affects earlier token boundaries.Medium7Two pointersPrefix sumNo attempts yet1s128 MBJudgeable
Protecting the VegetablesFind the minimum-perimeter rectangle of any orientation that encloses all given points.Medium7GeometrySorting+1No attempts yet2s128 MBJudgeable
Interstellar TradePlace the two ends of a wormhole on a line of planets to minimize the largest trip distance, where each trip uses the wormhole shortcut or the direct distance.Medium7Binary searchGreedy+2No attempts yet2s128 MBJudgeable
Line of SightCount the pairs of N points outside a central circle whose connecting segment avoids the circle.Medium7GeometrySorting+1No attempts yet1s128 MBJudgeable
Easy GeometryFind the largest area of an axis-aligned rectangle that fits inside a given convex polygon.Medium7GeometryTwo pointersNo attempts yet1s128 MBJudgeable
Width of a Point SetGiven up to 100000 points, compute the integer part of the squared minimum width of a strip enclosing all points.Medium7GeometryTwo pointersNo attempts yet2s512 MBJudgeable
Around the worldFor each plane range, find the fewest refueling landings to circle all airports from the best start, or report impossible.Medium7GreedyPrefix sum+1No attempts yet5s24 MBJudgeable
XH CompanyFor each query day D, report the length of the shortest suffix ending on day D-1 with the largest average.Medium7StackPrefix sum+1No attempts yet2s256 MBJudgeable
HighwayGiven up to 200,000 points per test case, output the lexicographically smallest pair with the largest Euclidean distance.Medium7GeometrySorting+1No attempts yet2s256 MBJudgeable
Mailing OrigamiFind the area of the smallest rotated rectangle enclosing N given points, rounded to the nearest integer.Medium7GeometrySorting+1No attempts yet1s256 MBJudgeable
Trapped in the HaybalesBessie breaks any bale smaller than her running start, and you must find the cheapest single bale to enlarge so she never leaves the outer bales.Medium7Two pointersSorting+1No attempts yet1s256 MBJudgeable
JoggingFor each rest point given in increasing order, print the largest angle in radians to a star with greater x, or zero when no such star exists.Medium7GeometrySorting+1No attempts yet1s16 MBJudgeable
Consecutive OrderingDecide whether every vertex's closed neighbourhood forms one unbroken block in the given vertex ordering.Medium7IntervalsTwo pointers+1No attempts yet1s256 MBJudgeable
Cake cutCarol picks a vertex of a convex cake and Carla picks a diagonal from it to split the cake, then Carol keeps the larger piece under optimal play from both.Medium7GeometryGame theory+1No attempts yet3s256 MBJudgeable
Angry CowsFind the smallest launch power whose chain of shrinking blast radii clears all hay bales on a line.Medium7Binary searchDynamic programming+1No attempts yet2s512 MBJudgeable
Sums of Sums (Large)Given a positive array, sort all its subarray sums and answer the sum of entries ranked L through R for each query.Medium7Binary searchTwo pointers+1No attempts yet5s512 MBJudgeable
Street Tree Props (Large)Assign one or two sticks to each of N trees so every tree reaches support B while the total used force is as small as possible.Medium7GreedySorting+1No attempts yet5s512 MBJudgeable
Train in a TunnelGiven car lengths and light states, find the minimum number of extra lights to turn on so that at every moment some lit car overlaps the tunnel.Medium7ArrayTwo pointers+2No attempts yet2s256 MBJudgeable
Splitting a StringChoose K non-overlapping substrings of A that also appear in B in the same non-overlapping order, maximizing their total length.Medium7Dynamic programmingString+1No attempts yet2s512 MBJudgeable
Hongjun's matrixGiven sequences A and B of length N, find the K-th smallest value among all N^2 products A_i * B_j.Medium7Binary searchSorting+2No attempts yet2s512 MBJudgeable
Partition into segments 2Split the array into at most M contiguous segments, minimizing the maximum difference between the largest and smallest value within any one segment.Medium7Binary searchDynamic programming+2No attempts yet2s512 MBJudgeable
Integral PolygonsCount the diagonals of a convex polygon that split it into two pieces of integer area, given integer vertex coordinates.Medium7GeometryMath+2No attempts yet2s256 MBJudgeable
House RentalGiven facilities of k types on a line, find the integer location minimizing the largest distance to the nearest facility of each type, smallest such location on ties.Medium7Binary searchSorting+1No attempts yet2s512 MBJudgeable
The Club HallGiven plank lengths and a rectangular hall, decide whether each row can be spanned by one or two planks and find the fewest planks that cover the floor.Medium7GreedySorting+2No attempts yet2s512 MBJudgeable
Free WeightsTwo rows of dumbbells, each mass appearing twice, must be paired up; minimize the heaviest dumbbell that must be lifted.Medium7ArrayTwo pointers+2No attempts yet4s512 MBJudgeable
RivaFind two points on a left-to-right non-self-intersecting polyline whose allowed chord length is within L and maximizes the area between the chord and the polyline above it.Medium7GeometryTwo pointers+1No attempts yet2s64 MBJudgeable
Team BuildingCount pairs of K-cow teams, one from each farmer, such that after sorting both teams John's cow beats Paul's in every paired rank, modulo 1000000009.Medium7SortingCombinatorics+2No attempts yet2s512 MBJudgeable
Smallest Square 2Given N lattice points, choose an axis-aligned square with lattice corners containing at least K points strictly inside and minimize its area.Medium7Binary searchSorting+2No attempts yet2s512 MBJudgeable
Proving PropositionsChoose directed edges so all N propositions become mutually reachable, minimizing the difference between the hardest and easiest chosen proof difficulties.Medium7GraphTwo pointers+2No attempts yet2s512 MBJudgeable
Longest Palindromic SubstringGiven a lowercase string of up to 100,000 characters, report the length of its longest palindromic substring.Medium7StringString matching+2No attempts yet2s512 MBJudgeable