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 results1,798 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
EmpodiaGiven a permutation biosequence, find every minimal framed interval: a segment whose endpoints are its min and max and that contains no shorter framed interval.Hard8StackArray+2No attempts yet1s128 MBJudgeable
IciclesIcicles grow each hour when strictly longer than both neighbors and snap at length L; find the hour when all have broken.Hard8SimulationImplementation+2No attempts yet1s128 MBJudgeable
Ladder GameGiven a ladder with n lines and m rungs, erase at most one rung to minimize the sum of scores reached from the leftmost k starting lines.Hard8ImplementationSimulation+2No attempts yet1s128 MBJudgeable
Jousting TournamentGiven the starting order of N-1 knights and C fixed round intervals, find the smallest insertion position for a late knight with skill R that maximizes the number of rounds it wins.Hard8ArraySimulation+2No attempts yet1s256 MBJudgeable
PaybackFriends stand at positions 1 to N with signed debts; Bessie starts at 0 holding nothing, must never go negative, and finishes at N. Find the minimum walking distance to settle all accounts.Hard8GreedyArray+1No attempts yet1s128 MBJudgeable
Milk PatternsGiven N integers, find the length of the longest contiguous subsequence that repeats at least K times, counting overlapping occurrences.Hard8String matchingBinary search+2No attempts yet1s128 MBJudgeable
Video SurveillanceGiven a rectilinear simple polygon, decide whether one point exists from which the whole interior is visible.Hard8GeometryImplementation+2No attempts yet1s128 MBJudgeable
Frequent ValuesFor each range query on a sorted array, output how many times the most frequent value occurs inside the range.Hard8Segment treeDivide and conquer+1No attempts yet1s128 MBJudgeable
GerrymanderingMerge adjacent ridings into blocks so Party 1 strictly wins a majority of the remaining ridings, minimizing the number of merges.Hard8Dynamic programmingPrefix sum+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
HighwaysGiven N cities on a line with one-way roads only left to right, add two non-touching one-way roads to make the network strongly connected at minimum total length, or print 0.Hard8GreedyImplementation+2No attempts yet1s512 MBJudgeable
Key InsertionSimulate the recursive Insert operation on an infinite array for N keys and print the final occupancy up to the largest filled cell.Hard8Union-findImplementation+2No attempts yet1s512 MBJudgeable
Cyclic Rotation CipherReconstruct the original lowercase string from its Burrows-Wheeler transform index i and last column R.Hard8StringSorting+1No attempts yet1s32 MBJudgeable
Log AnalysisMaintain a volatile log under insertions in the middle, block deletions, and queries asking how many distinct event types appear in a position range.Hard8ArraySegment tree+2No attempts yet2s256 MBJudgeable
Knowledge for the MassesEach row's racks keep their order and can shift left or right at cost 1 per rack; find the cheapest passage position and all positions attaining it.Hard8GreedyPrefix sum+2No attempts yet1s512 MBJudgeable
Arithmetic RectangleGiven an n by m grid of integers, find the largest rectangle in which every row and every column forms an arithmetic sequence, and output its area in unit squares.Hard8Dynamic programmingArray+2No attempts yet3s128 MBJudgeable
RadioGiven a circle and a simple polygon, compute the area of the polygon's interior that lies inside the circle.Hard8GeometryArrayNo attempts yet1s128 MBJudgeable
Catching MolesChoose at most k holes to shoot on a circle; each shot removes the target's moles and pushes neighbors' moles outward, maximizing the total removed.Hard8Dynamic programmingGreedy+2No attempts yet1s256 MBJudgeable
WindowGiven an orthogonal polygon and an axis-parallel window, count how many separate interior fragments of the polygon are visible through the window.Hard8GeometryImplementation+1No attempts yet1s128 MBJudgeable
Gas PipelinesAssign each of n extraction points to a distinct station southeast of it, minimizing the total Manhattan distance.Hard8GreedySorting+1No attempts yet1s128 MBJudgeable
MeteorsEach of N states owns sectors on a circle; given Q meteor showers that add a value to a sector range, find the earliest day each state's total reaches its target, or report it never does.Hard8Binary searchPrefix sum+2No attempts yet5s256 MBJudgeable
Bark BeetlesTwo beetles alternate taking one end picket or both end pickets from a row; each maximizes its own total, so find both final totals.Hard8Dynamic programmingGame theory+2No attempts yet1s128 MBJudgeable
TetrisEach block is a horizontal strip 1 unit tall; given its length and left offset, choose the drop order that minimizes the final stack height. Output that minimum.Hard8GreedySorting+2No attempts yet1s128 MBJudgeable
Power of the ArrayGiven an array and t range queries, compute for each subarray the sum over values s of s times the square of s's frequency in the range.Hard8ArrayPrefix sum+2No attempts yet3s128 MBJudgeable
How Big Are the Pockets? (Large)A run-length-encoded turtle walk traces a simple closed lattice polygon; compute the total area of all points outside it that have boundary both east and west or both north and south.Hard8GeometrySimulation+2No attempts yet5s512 MBJudgeable
WhiteboardGiven a path on a grid and a target pattern, find the smallest and largest drying timestep T so the final board matches the target.Hard8SimulationImplementation+2No attempts yet5s512 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
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
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
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
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
LefkaritikaGiven a grid with blocked points, count the maximum number of axis-aligned square items of any side length that can be placed without covering blocked points, respecting placement order and same-size non-overlap rules.Hard8ArrayDynamic programming+2No attempts yet2s512 MBJudgeable
ShoppingGiven an array of prices and a sequence of queries (money, l, r), simulate a shopper who spends as much as possible at each product from l to r and report the leftover money.Hard8ArraySegment tree+2No attempts yet5s512 MBJudgeable
Maximum Bitwise OR by Window LengthFor each window length K from 1 to N, output the maximum bitwise OR over all K consecutive elements of the array.Hard8Bit manipulationDivide and conquer+2No attempts yet2s512 MBJudgeable
Sticks and CarrotsChoose a subset of at least three vertices of a convex polygon so every carrot lies strictly inside the new polygon, minimizing its area.Hard8GeometryDynamic programming+2No attempts yet2s512 MBJudgeable
Safe Squares (Large)Count all grid-aligned square regions of any size that contain no monster, given a sparse set of at most K monster cells on an R by C board.Hard8ArrayDynamic programming+2No attempts yet5s512 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
Sequence and Queries 18Maintain an array under point updates and answer range queries counting elements greater than k.Hard8Segment treeSorting+2No attempts yet2s512 MBJudgeable
Aztec DiamondGiven a domino tiling of an Aztec diamond, find the shortest sequence of 2x2 rotations that turns all bricks vertical, lexicographically smallest.Hard8GreedySimulation+2No attempts yet1s128 MBJudgeable
Gathering clamsGiven an N by N grid of clam limits, compute after each of N single-cell +1/-1 updates the sum over all cells of the maximum-weight monotone staircase path to the top-left.Hard8Dynamic programmingPrefix sum+1No attempts yet2s512 MBJudgeable
MonstersGiven a binary N x M grid, choose one intact cell to destroy so that the number of all-1 submatrices remaining is minimized, and report that minimum count.Hard8ArrayDynamic programming+2No attempts yet1s32 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
Abstract ArtGiven up to 100 simple polygons with 3 to 20 vertices each, compute the sum of their areas and the area of their union, each rounded to six decimals.Hard8GeometryImplementation+1No attempts yet2s512 MBJudgeable
Kitchen KnobsGiven n seven-digit knobs, find the fewest range rotations (each turning a contiguous block by the same amount) so every knob reads its maximum-power digit.Hard8GreedyImplementation+2No attempts yet3s512 MBJudgeable
Wookje and His FansMaintain a line of fans with club labels under deletions and range-count queries, where each query counts the maximal same-club run around an element.Hard8Linked listUnion-find+2No attempts yet2.5s256 MBJudgeable
Winning SegmentsGiven a permutation of 0..2^M-1, count the nonempty subarrays whose XOR can be made equal to 2^M-1 by one mandatory swap of two elements.Hard8Bit manipulationPrefix sum+2No attempts yet4s256 MBJudgeable
MiningGiven a grid of mineral strengths with air only on the top, left, and right faces, find the smallest performance D so that at least K minerals can be removed in some order.Hard8Binary searchBFS+2No attempts yet2s256 MBJudgeable
Ascending PhotoGiven a sequence of n heights, find the minimum number of cuts so the pieces can be reordered into a nondecreasing sequence.Hard8GreedySorting+2No attempts yet3s512 MBJudgeable
Single Cut of FailureWires cross a rectangle between boundary sides; find the fewest straight cuts connecting different sides that cross every wire, and output the lexicographically smallest such cut.Hard8GeometrySorting+2No attempts yet6s1024 MBJudgeable
Snow BootsFor each of B boots with limits on snow depth and step length, decide whether the farmer can walk from tile 1 to tile N, landing only on tiles whose snow is shallow enough.Hard8Binary searchSorting+2No attempts yet2s512 MBJudgeable
Nordic CampingGiven a grid with rocky cells blocked, answer queries each asking for the area of the largest all-usable square subgrid that contains a specified water source cell.Hard8Dynamic programmingBinary search+2No attempts yet2s512 MBJudgeable
Magic NecklaceFor each of the N cut positions on a circular array, fuse contiguous segments into one bead equal to their gcd so that every resulting bead is 1, and report the maximum bead count.Hard8MathNumber theory+2No attempts yet2s512 MBJudgeable
Монгол ардын үлгэрChoose a subset whose size is at most the total weight of the remaining stones, maximizing the value of that chosen subset.Hard8Dynamic programmingSorting+2No attempts yet2s512 MBJudgeable
Baek ChaewonFind the homes where Baek Chaewon can always escape K equal-speed followers from node 1 along a shortest path in an undirected weighted graph.Hard8GraphShortest path+2No attempts yet2s512 MBJudgeable
ClustersPartition companies 1..N into contiguous clusters, each led by its first or last company whose limit L_i caps the size, minimizing the sum of C_i*S + T_i over leaders.Hard8Dynamic programmingPrefix sum+2No attempts yet3s1024 MBJudgeable
Array StudyFor each of q subarray queries on an array of 1 and -1, find the longest zero-sum subarray inside it, and print the sum of these lengths.Hard8Prefix sumDivide and conquer+2No attempts yet2s512 MBJudgeable
cmpStore which of 12-bit buckets hold the remembered 12-bit value with 4095 bits, then read 12 prefix sums to binary search the bucket and compare it by a 12-bit count table to fit 20 memory accesses.Hard8Bit manipulationBinary search+2No attempts yet10s256 MBJudgeable
k-Maximum SubarraysPick k disjoint contiguous subarrays of an array with maximum total sum; output only that sum.Hard8Dynamic programmingDivide and conquer+2No attempts yet2s512 MBJudgeable
A Sequence That Matches Front and BackChoose how many elements to cut from the array's front so that, if the rest is a k-front-back sequence, k is as large as possible or no k exists. Return k and the cut count.Hard8ArrayString matching+1No attempts yet2s128 MBJudgeable
Bad KemingFill every gap in the spaced copy of S with chosen letters to make the longest prefix of S a contiguous substring, and find that prefix length.Hard8String matchingString+2No attempts yet2s512 MBJudgeable
The ABCD MurdererFind the fewest word occurrences needed to cover a target text exactly when cut-outs may overlap on matching text, or report -1 if impossible.Hard8String matchingArray+2No attempts yet2s512 MBJudgeable
Fibonacci NimFind which piles lose the Fibonacci-Nim take-away game and decide the winner of the multi-pile sum game with optimal play.Hard8Game theoryMath+2No attempts yet0.5s512 MBJudgeable
Maximum Subarray Sum and QueriesGiven an array, answer queries that ask for the maximum subarray sum inside a given index range.Hard8Segment treeDivide and conquer+2No attempts yet2s512 MBJudgeable
Rope and QueriesMaintain a string under up to 100,000 queries that cut a substring and move it to the front or back, and print single characters.Hard8Linked listImplementation+2No attempts yet0.3s512 MBJudgeable
RedistrictingGiven a string of H and G representing a line of cows, split it into contiguous districts of length at most K minimizing the number of districts where G outnumbers or ties H.Hard8Dynamic programmingPrefix sum+2No attempts yet2s512 MBJudgeable
Truth TellersGiven N people each stating a range for the number of truth tellers, find the maximum consistent truth-teller count after each of Q point updates.Hard8ArraySegment tree+2No attempts yet3.5s256 MBJudgeable
Circular DNAGiven a circular sequence of start and end markers for many gene types, choose a cut position that maximizes how many gene types have their markers properly nested in the resulting linear subsequence.Hard8ArrayStack+2No attempts yet3s512 MBJudgeable
Random Number GeneratorSimulate a quadratic-polynomial generator to build a grid, then find the path from top-left to bottom-right whose sorted values are lexicographically smallest.Hard8SimulationGreedy+2No attempts yet3s256 MBJudgeable
Copy and Paste 2Simulate N copy-and-paste edits on a string capped at length M, tracking positions backward so the first K characters of the final string can be printed.Hard8ImplementationBinary search+2No attempts yet1s512 MBJudgeable
Computer CacheMaintain a mutable byte array over m pieces, support range increments modulo 256 on a piece, cache loads of whole pieces into fixed cache positions, and point queries of cache bytes.Hard8Segment treeArray+2No attempts yet5s512 MBJudgeable
GrudanjeGiven a word and Q substrings, find the first snowball throw index (in a given order of positions) after which no substring contains two uncovered equal letters.Hard8ArrayBinary search+2No attempts yet2s512 MBJudgeable
Close NumbersGiven a permutation p and q range queries [l, r], find the minimum absolute difference between any two values in the subarray p[l..r].Hard8ArraySorting+2No attempts yet2s512 MBJudgeable
Hero's HistogramGiven a histogram of n columns, for every prefix of the first j columns report the largest axis-aligned rectangle that fits inside that prefix.Hard8StackPrefix sum+2No attempts yet1s512 MBJudgeable
Farmer John Solves 3SUMCount, for each of Q queries, the number of unordered index triples in the subarray A[a..b] whose values sum to zero.Hard8Dynamic programmingPrefix sum+2No attempts yet2s512 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
Exciting MenusGiven N strings with a joy value per position, maximize over all substrings the product of its length, the joy at its end, and the number of strings having it as a prefix.Hard8TrieString+2No attempts yet4s512 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
Wavel SequenceCount pairs of increasing index sequences from two arrays whose selected values are equal and form a strictly alternating up-down wave, modulo 998244353.Hard8Dynamic programmingCombinatorics+2No attempts yet1s512 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
Counting in the OrderEach soldier looks left or right and sees past people no taller than the target; count how many soldiers each one sees.Hard8StackArray+2No attempts yet1s512 MBJudgeable
Equal MaximumsCount quadruples of indices i<=j<k<=l where the maximum of a[i..j] equals the maximum of a[k..l], modulo 1e9+7, for n up to 100000.Hard8ArrayStack+2No attempts yet1s512 MBJudgeable
Mine the GradientGiven a grayscale grid, find the largest square subgrid whose values follow a vertical, horizontal, or diagonal uniform gradient, and report its area.Hard9Dynamic programmingImplementation+2No attempts yet10s128 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
ArrayStart with array a_i = i, apply up to 300000 queries that reverse or rotate subarrays and ask for range min, max, sum, value at index, or index of a value, then print the final array.Hard9ArrayImplementation+2No attempts yet1s512 MBJudgeable
The Kingdom of JOIOIPartition an H by W grid into two connected regions whose row and column slices are contiguous, minimizing the larger altitude range within either region.Hard9Binary searchGreedy+2No attempts yet4s256 MBJudgeable
RopeA rope of N unit cords with colors is repeatedly folded in half, paying the thickness of cords whose colors are changed, until length 2; for each color report the minimum total cost to end with a cord of that color.Hard9Dynamic programmingDivide and conquer+2No attempts yet2.5s256 MBJudgeable
Shifty GridApply a fixed two-phase procedure of cyclic row and column shifts to sort a permutation grid into row-major order, following the exact TURN steps given.Hard9SimulationImplementation+2No attempts yet2s512 MBJudgeable
Imelda's Shopping SpreeMaintain a sequence of prices under range-add and range-reverse, and after each update output the number of contiguous segments whose values are strictly increasing.Hard9Segment treeArray+2No attempts yet5s512 MBJudgeable
L-th K-th numberGiven N cards, take the K-th smallest value of every contiguous block of length at least K, then report the L-th smallest of all those values.Hard9Binary searchArray+2No attempts yet2s512 MBJudgeable
International Cow Lineup Photo ContestGiven a 0/1 array and up to 1e5 adjacent swaps, after each swap report the longest subarray with equal numbers of 0s and 1s.Hard9Segment treePrefix sum+2No attempts yet2s512 MBJudgeable
Maintaining a SequenceMaintain a sequence under insert, delete, range assign, reverse, range sum, and global maximum subarray queries.Hard9Dynamic programmingImplementation+2No attempts yet2s256 MBJudgeable
Traveling MerchantGiven weekly price cycles at n towns, answer q queries for the max profit from buying and later selling during a trip from town s to town t.Hard9Segment treeDivide and conquer+2No attempts yet10s1024 MBJudgeable
HotelMaintain an array under point height updates; after each update answer queries for the longest subsegment inside [l, r] that contains no strict interior valley.Hard9Segment treeArray+2No attempts yet2s512 MBJudgeable
Historical ResearchFor each query range, report the maximum over event types t of t times the count of t inside the range.Hard9Divide and conquerArray+2No attempts yet4s512 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
OR and QueriesProcess range bitwise-OR updates on an array and count how many positions in a range currently equal a fixed K.Hard9Segment treeBit manipulation+2No attempts yet1.5s256 MBJudgeable
AtomsMaintain a sequence of charges under range add updates, and after restricting to a query segment, report the longest run of consecutive positions where each next charge exceeds the previous by exactly one.Hard9Segment treeDynamic programming+2No attempts yet2s512 MBJudgeable