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
Jurisdiction DisenchantmentGiven n odd points, find the smallest axis-aligned rectangle (possibly degenerate) that contains strictly more than n/2 of them, and output its area.Medium7ArraySorting+2No attempts yet2s512 MBJudgeable
Faster SortingFor each MINRUN, simulate Timsort's run splitting and report the number of subarrays and the number of bad elements pulled in.Medium7SimulationTwo pointers+1No attempts yet1s128 MBJudgeable
Tent DutyCount sets of two points on each of two parallel lines that form a trapezoid with both bottom angles acute or both top angles acute.Medium7GeometrySorting+2No attempts yet1s128 MBJudgeable
Horror Film NightGiven the sets of days each of two people likes films on, find the longest subsequence with no two consecutive films disliked by the same person.Medium7GreedyTwo pointers+1No attempts yet2s512 MBJudgeable
Kayaking TripGiven counts of three strength levels and kayak speed factors, pair everyone two to a kayak to maximize the slowest kayak's speed.Medium7GreedySorting+2No attempts yet2s512 MBJudgeable
Breaking BiscuitsGiven a simple polygon, find the smallest diameter of a circular mug that can contain it in some orientation, i.e. the polygon's minimum width.Medium7GeometryTwo pointers+1No attempts yet1s512 MBJudgeable
Biotechnology laboratoryGiven a string of lowercase letters weighted 1 to 26, count how many distinct total weights occur among all non-empty substrings.Medium7Prefix sumTwo pointers+2No attempts yet7s1024 MBJudgeable
Global WarmingFind the longest subarray whose minimum value and maximum value each occur exactly once, and report its length and earliest start.Medium7Two pointersStack+1No attempts yet2s512 MBJudgeable
Buying Card PacksChoose M non-overlapping length-L windows in a card row, each window free of duplicate kinds, and find the largest feasible L.Medium7Binary searchGreedy+2No attempts yet1s512 MBJudgeable
CipeleMatch as many left/right shoe pairs as possible, as long as no further pair can be formed, and minimize the largest size gap.Medium7Binary searchGraph+2No attempts yet1s64 MBJudgeable
Acute TrianglesGiven n points, count the triangles with all three angles under 90 degrees. Total n across all test cases is at most 2000.Medium7GeometryTwo pointers+2No attempts yet4s512 MBJudgeable
Playing the Smaller NumberGiven two odd-length card sets, decide if one player can force a majority of rounds by winning when their card is strictly smaller, using a matching strategy.Medium7SortingGreedy+1No attempts yet1s512 MBJudgeable
Selling RNA StrandsGiven N RNA strings, answer M queries that count strings matching a prefix P and suffix Q.Medium7String matchingHash map+2No attempts yet1.5s1536 MBJudgeable
Subsequences in SubstringsCount how many substrings of s contain t as a subsequence at least once.Medium7Two pointersDynamic programming+2No attempts yet2s512 MBJudgeable
Dynamic RollerFor each tile i, count the tiles to its right whose viscosity B is at most A_i, given B is nondecreasing.Medium7Binary searchArray+2No attempts yet2s512 MBJudgeable
Alphabet StringCount distinct strings formed by sorting the distinct characters of every substring of an uppercase string and removing duplicates.Medium7StringHash map+2No attempts yet1s256 MBJudgeable
Blurred PicturesEach row gives a contiguous run of good pixels [ai, bi]; find the largest axis-aligned square whose every pixel is good.Medium7ArrayTwo pointers+2No attempts yet2s512 MBJudgeable
FishGiven N fish with lengths and one of three colors, count the distinct color-count triples achievable by a set of fish where no two have a length ratio of 2 or more.Medium7SortingTwo pointers+1No attempts yet1.5s512 MBJudgeable
Mixing DrinksCount the ways to split the sequence 1..N into consecutive nonempty blocks so that no block contains both endpoints of any listed bad pair, modulo 1e9+7.Medium7Dynamic programmingTwo pointers+2No attempts yet1s512 MBJudgeable
Bus TicketGiven trip days in non-decreasing order, single-trip price s, and a ticket costing p that covers m days from purchase, find the minimum total cost.Medium7Dynamic programmingGreedy+2No attempts yet1s512 MBJudgeable
Eggfruit CakeCount the circular contiguous slices of a fruit border that contain at least one eggfruit ('E') and at most S fruits, where slices are distinguished by which fruits they include.Medium7Two pointersSliding window+2No attempts yet0.1s512 MBJudgeable
Deep800080Place a point on a line so that a disk of fixed radius R centered there covers as many of N given points as possible; output the maximum count.Medium7GeometrySorting+2No attempts yet2s512 MBJudgeable
Sum and ProductCount the subarrays of length at least 2 in which the sum of the elements equals their product, where each element is a positive integer up to 1e9.Medium7Two pointersMath+2No attempts yet2s512 MBJudgeable
Trous de LoupGiven n weighted positions, a sandbag budget p, and a plank covering d consecutive positions, find the longest contiguous segment that can be fully disarmed.Medium7Sliding windowTwo pointers+2No attempts yet2s512 MBJudgeable
Matrix SumCount the submatrices of an N by M matrix whose element sum is at most x.Medium7Prefix sumTwo pointers+2No attempts yet2s256 MBJudgeable
Nested Reversal SequenceGiven two binary strings, find the minimum number of substring reversals, each interval nested inside the previous one, needed to turn the first string into the second, or report impossibility.Hard8StringGreedy+2No attempts yet2s128 MBJudgeable
Minimum-Cost Number Matching (Hard)Given sorted sets S and T, choose pairs (s,t) with cost |s-t| so every element of both sets appears in at least one pair, minimizing total cost, for sizes up to 500000.Hard8Dynamic programmingGreedy+2No attempts yet2s128 MBJudgeable
Tug of WarSplit two weighted sequences each into three ordered nonempty contiguous parts so paired-part weight differences stay under 50 and the maximum difference is minimized.Hard8Binary searchPrefix sum+1No attempts yet1s128 MBJudgeable
CraneGiven N boxes each holding two colored balls, output a shortest crane command sequence that rearranges balls so all-white boxes and all-black boxes form contiguous groups.Hard8GreedySimulation+1No attempts yet1s128 MBJudgeable
DistanceGiven a walk on a grid, find a contiguous segment of moves to delete so the remaining path stays within a bounding rectangle and ends as close as possible to the target point.Hard8Prefix sumTwo pointers+2No attempts yet1s128 MBJudgeable
WormlyFind the minimum number of moves to shift a worm's body window and its ordered legs across a bridge with missing planks, or report impossibility.Hard8GreedyTwo pointers+1No attempts yet1s128 MBJudgeable
SignalGiven n points with no three collinear and no four concyclic, average over all triples the number of points inside or on the circle through the triple.Hard8GeometryCombinatorics+2No attempts yet2s128 MBJudgeable
Pie DivisionCount the number of straight lines that split 2N labeled points (N of each of two colors, N even) so that each open half-plane holds N/2 points of each color, treating both sides as the same split.Hard8GeometryCombinatorics+2No attempts yet2s256 MBJudgeable
Triangle CountingCount how many triangles formed by triples of N integer points strictly contain the origin in their interior.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
A Strip of LandGiven a U by V grid of heights, find the largest-area rectangle whose height range is at most C and whose width is at most 100.Hard8Sliding windowMatrix+2No attempts yet2s128 MBJudgeable
RobotsRobots on a circular track move clockwise for given durations, pushing each other and stopping at walls; find each final position.Hard8SimulationIntervals+2No attempts yet1s1024 MBJudgeable
Fortune at El DoradoGiven up to 1000 points on a 1000x1000 grid and a maximum area A, find an axis-parallel rectangle with positive integer area at most A containing the most points.Hard8Two pointersBinary search+2No attempts yet1s128 MBJudgeable
Crossed MatchingsGiven two rows of positive integers, draw the maximum number of equal-value matching segments between the rows so that each segment crosses exactly one other and no number is used twice.Hard8Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
Almost ClearGiven two disjoint convex polygons A and B and a point C outside both, decide whether B hides none, part, or all of A as seen from C.Hard8GeometryBinary search+2No attempts yet1s128 MBJudgeable
Empty CuboidsGiven up to 5000 integer points, find the largest axis-aligned box anchored at the origin whose strict interior contains none of the points, and output its volume.Hard8SortingTwo pointers+2No attempts yet3s128 MBJudgeable
The InvasionGiven a convex polygon with n vertices and m weighted points, find three polygon vertices forming a triangle with the maximum total weight of points inside or on it.Hard8GeometryTwo pointers+2No attempts yet3s64 MBJudgeable
PloughingGiven an m by n grid of tile difficulties, repeatedly remove a full strip of width 1 from any edge as long as the strip sum is at most k, and minimize the number of strips that remove every tile.Hard8Dynamic programmingTwo pointers+2No attempts yet1s128 MBJudgeable
FrogFor each rock, find where a frog lands after exactly m leaps, where each leap goes to the k-th nearest rock with ties broken toward the spring.Hard8Two pointersBinary search+1No attempts yet3s512 MBJudgeable
Sum of PolygonsAdd two convex polygons by Minkowski sum and print twice the area of the resulting polygon.Hard8GeometryTwo pointers+2No attempts yet1s128 MBJudgeable
BajtoriSelect a subset of squares to maximize the sum of the squared red total and squared green total.Hard8GeometrySorting+1No attempts yet1s128 MBJudgeable
Fence In Godzilla!The task is to find the smallest nonzero area among triangles with vertices from n points.Hard8GeometrySorting+1No attempts yet1s128 MBJudgeable
The Avaricious ISPChoose two disjoint disks over weighted points to maximize the product of the covered weight sums.Hard8GeometrySorting+1No attempts yet1s128 MBJudgeable
Golf FieldChoose four of up to 30000 points in the plane so their convex hull has the largest possible area.Hard8GeometryTwo pointersNo 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
Turning off the bulbsCount the possible turn-off orders when an interval expands from a start bulb by always taking the stronger of the two frontier bulbs, branching on ties.Hard8CombinatoricsTwo pointers+1No attempts yet1s512 MBJudgeable
Longest Shortest Paths at ShymbulakCount every shortest path between all vertex pairs at the maximum distance in a connected graph with N vertices and N equal edges.Hard8GraphBFS+2No attempts yet2s256 MBJudgeable
Marriage questionsCount the candidate intervals [L, R] in which all M daughters can each marry a distinct candidate they accept.Hard8GraphTwo pointersNo attempts yet2s256 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
BillboardGiven a 0/1 matrix, find the largest all-1 sub-rectangle after flipping at most s zeros and clearing at most r rows entirely.Hard8Sliding windowTwo pointers+2No attempts yet2s512 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
Keeping the Dogs ApartTwo dogs follow their own polyline routes at the same constant speed; find the minimum distance between them while both are still walking.Hard8GeometryTwo pointers+2No attempts yet6s512 MBJudgeable
Triangle regionsGiven N points with no three collinear, count for each v how many triangles formed by three points contain exactly v other points strictly inside.Hard8GeometryCombinatorics+2No attempts yet2s512 MBJudgeable
I Teach SweepingGiven segments in the first quadrant, find a line through the origin that intersects the most segments and report that count.Hard8GeometrySorting+1No attempts yet2s512 MBJudgeable
Subsequence ReversalReverse one subsequence of a length-N array, then find the longest non-decreasing subsequence length achievable.Hard8Dynamic programmingArray+2No attempts yet2s512 MBJudgeable
Over Fitting (Large)Given N labeled points in the plane, find a line whose positive half-plane contains only LOVELYZ points and maximizes how many LOVELYZ points it captures.Hard8GeometrySorting+2No attempts yet3s512 MBJudgeable
Two-Headed CowsN cows each have two heads, and M dislike pairs require that those heads face opposite troughs. Split the cows into the fewest consecutive blocks that each admit a valid orientation.Hard8GraphUnion-find+1No attempts yet2s512 MBJudgeable
Rectilinear RegionsGiven two unbounded staircase polylines L and U, count the closed regions they enclose with L below and U above, and sum their areas.Hard8GeometryTwo pointers+2No attempts yet0.5s512 MBJudgeable
Shooting GalleryA row of ducks, each with a species; a good round hits two ducks of the same species and keeps only the ducks strictly between them, and rounds continue while same-species pairs remain. Find the longest possible run of good rounds.Hard8Dynamic programmingArray+2No attempts yet2s512 MBJudgeable
Ice cream samplesGiven a circular sequence of sample boxes, find the shortest consecutive run whose multiset union covers all brands 1 to K, and report its total sample count.Hard8Sliding windowTwo pointers+2No attempts yet3s512 MBJudgeable
HubtownAssign citizens to one of their two angularly nearest train rays, respecting each ray's capacity, and maximize the number assigned.Hard8GreedySorting+2No attempts yet10s512 MBJudgeable
The Infosci Pirate CrewGiven N islands with coordinates, treasure values, and safe hardness, choose a monotone northeast path and a hardness interval to maximize collected value minus interval length.Hard8Dynamic programmingSorting+2No attempts yet1s512 MBJudgeable
Computer ScienceFind the smallest L such that for each a_i we can pick an interval [x_i, x_i+L] covering a_i and containing at least K of the given integers.Hard8Binary searchSorting+2No attempts yet2s512 MBJudgeable
RecipeBuy ingredients on some days, hold each in the fridge until a later day, cook it there if freshness stays at least L_i, and maximize the total of F_i minus elapsed days times C_j; print Impossible if day N can't be a cooking day.Hard8Dynamic programmingGreedy+2No attempts yet1s1024 MBJudgeable
ParticlesGiven firing times and speeds of N particles from each of two facing accelerators, report the first K collisions between opposite kinds in chronological order.Hard8SortingTwo pointers+2No attempts yet2s512 MBJudgeable
Pineapple PizzaGiven n points and a center Q, decide whether k rays from Q can split the plane so every sector holds exactly n/k points, with no point on a ray.Hard8GeometrySorting+2No attempts yet1s256 MBJudgeable
Fair ShareGiven n weighted points around the origin, choose a line through the origin that splits them into two half-planes, minimizing the absolute difference of the two half-plane weight sums.Hard8GeometrySorting+2No attempts yet5s512 MBJudgeable
PanokseonSplit a sequence of n positive weights into groups with sum at most W to minimize the maximum of (W minus group sum) squared.Hard8GreedyBinary search+2No attempts yet1s512 MBJudgeable
ParcelGiven n distinct integers and target w, decide whether four of them sum exactly to w.Hard8Two pointersHash map+1No attempts yet1s512 MBJudgeable
Isomorphic InversionSplit a digit string into the largest number of contiguous pieces whose sequence of pieces reads the same forward and backward.Hard8GreedyString matching+2No attempts yet1s512 MBJudgeable
Cow DatingGiven probabilities p_i, choose a contiguous interval maximizing the chance that exactly one bull accepts, and print 10^6 times that probability rounded down.Hard8MathTwo pointers+2No attempts yet2s512 MBJudgeable
String DecorationGiven a string S and N pattern strings, find the length of the shortest substring of S that contains every pattern as a substring.Hard8StringSliding window+2No attempts yet2s512 MBJudgeable
Paris by NightGiven N graded points in general position, pick two boundary monuments and split the rest by the line through them to minimize the absolute difference of the two side sums.Hard8GeometrySorting+2No attempts yet15s512 MBJudgeable
SpyGiven a subordinate subtree for every leader in two rooted trees of N employees, count for each IOI employee how many of the M spy projects succeed, where spy b succeeds when the matching JOI employee lies in research project b's subtree.Hard8TreeDFS+2No attempts yet2s256 MBJudgeable
MeetingsCows on a line swap velocities when they meet, stop at barns, and the question asks how many meetings occur before half the total weight has stopped.Hard8SortingMath+2No attempts yet1s512 MBJudgeable
Movie-goerChoose a contiguous block of days maximizing the sum of weights of movies that appear exactly once in the block.Hard8ArrayTwo pointers+2No attempts yet5s512 MBJudgeable
ICPC CampGiven n days, p classical and q creative problems with difficulty values, pair one of each per day so every pair sums to at most s, minimizing the largest within-pair difference; output -1 if impossible.Hard8Binary searchGreedy+2No attempts yet4s512 MBJudgeable
New Year and Castle ConstructionGiven n points with no three collinear, count over all points p the number of 4-point subsets whose convex quadrilateral strictly contains p, and sum these counts.Hard8GeometryCombinatorics+2No attempts yet3s512 MBJudgeable
CartoonsCount subarrays in which every sub-subarray contains at least one value that appears exactly once, over a sequence of up to 500,000 values.Hard8Two pointersDivide and conquer+2No attempts yet2.5s256 MBJudgeable
Related LanguagesGiven strings A and B and an integer k, find the longest pair of equal-length substrings, one from each string, that differ in at most k positions.Hard8Binary searchDynamic programming+2No attempts yet10s512 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
CastingFor a convex polygon, count the vertex pairs whose connecting line splits it into two parts that can each be pulled out by translation.Hard9GeometryTwo pointers+2No attempts yet1s128 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
Gahui's Sequence Mod Play (Large)Maintain a stack under push and pop, and after each type 3 query report the shortest suffix whose remainders mod m cover every residue from 0 to m-1, printing -1 if impossible.Hard9StackTwo pointers+2No attempts yet1s256 MBJudgeable
Make Rounddog HappyCount subarrays whose elements are all distinct and whose maximum minus length is at most k, for arrays up to 300,000 with values bounded by n.Hard9Divide and conquerTwo pointers+2No attempts yet2s512 MBJudgeable