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
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| 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. | Hard8 | StackArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| IciclesIcicles grow each hour when strictly longer than both neighbors and snap at length L; find the hour when all have broken. | Hard8 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | ImplementationSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | ArraySimulation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Hard8 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Milk PatternsGiven N integers, find the length of the longest contiguous subsequence that repeats at least K times, counting overlapping occurrences. | Hard8 | String matchingBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Video SurveillanceGiven a rectilinear simple polygon, decide whether one point exists from which the whole interior is visible. | Hard8 | GeometryImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Frequent ValuesFor each range query on a sorted array, output how many times the most frequent value occurs inside the range. | Hard8 | Segment treeDivide and conquer+1 | No attempts yet | 1s | 128 MB | Judgeable |
| GerrymanderingMerge adjacent ridings into blocks so Party 1 strictly wins a majority of the remaining ridings, minimizing the number of merges. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GreedyImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Key InsertionSimulate the recursive Insert operation on an infinite array for N keys and print the final occupancy up to the largest filled cell. | Hard8 | Union-findImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Cyclic Rotation CipherReconstruct the original lowercase string from its Burrows-Wheeler transform index i and last column R. | Hard8 | StringSorting+1 | No attempts yet | 1s | 32 MB | Judgeable |
| 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. | Hard8 | ArraySegment tree+2 | No attempts yet | 2s | 256 MB | Judgeable |
| 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. | Hard8 | GreedyPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingArray+2 | No attempts yet | 3s | 128 MB | Judgeable |
| RadioGiven a circle and a simple polygon, compute the area of the polygon's interior that lies inside the circle. | Hard8 | GeometryArray | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 256 MB | Judgeable |
| WindowGiven an orthogonal polygon and an axis-parallel window, count how many separate interior fragments of the polygon are visible through the window. | Hard8 | GeometryImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Gas PipelinesAssign each of n extraction points to a distinct station southeast of it, minimizing the total Manhattan distance. | Hard8 | GreedySorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | Binary searchPrefix sum+2 | No attempts yet | 5s | 256 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingGame theory+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | ArrayPrefix sum+2 | No attempts yet | 3s | 128 MB | Judgeable |
| 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. | Hard8 | GeometrySimulation+2 | No attempts yet | 5s | 512 MB | Judgeable |
| 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. | Hard8 | SimulationImplementation+2 | No attempts yet | 5s | 512 MB | Judgeable |
| The Longest Welded SwordSelect and order all plates so that widths strictly decrease, orienting each plate to maximize the total contributed length sum. | Hard8 | GreedySorting+2 | No attempts yet | 7s | 512 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | IntervalsGreedy+2 | No attempts yet | 10s | 512 MB | Judgeable |
| 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. | Hard8 | SimulationImplementation+2 | No attempts yet | 8s | 512 MB | Judgeable |
| 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. | Hard8 | ArraySorting+2 | No attempts yet | 5s | 1536 MB | Judgeable |
| 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. | Hard8 | ArrayDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | ArraySegment tree+2 | No attempts yet | 5s | 512 MB | Judgeable |
| 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. | Hard8 | Bit manipulationDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | GeometryDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | ArrayDynamic programming+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Subsequence ReversalReverse one subsequence of a length-N array, then find the longest non-decreasing subsequence length achievable. | Hard8 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 18Maintain an array under point updates and answer range queries counting elements greater than k. | Hard8 | Segment treeSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Aztec DiamondGiven a domino tiling of an Aztec diamond, find the shortest sequence of 2x2 rotations that turns all bricks vertical, lexicographically smallest. | Hard8 | GreedySimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | ArrayDynamic programming+2 | No attempts yet | 1s | 32 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | Sliding windowTwo pointers+2 | No attempts yet | 3s | 512 MB | Judgeable |
| 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. | Hard8 | GeometryImplementation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | GreedyImplementation+2 | No attempts yet | 3s | 512 MB | Judgeable |
| 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. | Hard8 | Linked listUnion-find+2 | No attempts yet | 2.5s | 256 MB | Judgeable |
| 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. | Hard8 | Bit manipulationPrefix sum+2 | No attempts yet | 4s | 256 MB | Judgeable |
| 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. | Hard8 | Binary searchBFS+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Ascending PhotoGiven a sequence of n heights, find the minimum number of cuts so the pieces can be reordered into a nondecreasing sequence. | Hard8 | GreedySorting+2 | No attempts yet | 3s | 512 MB | Judgeable |
| 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. | Hard8 | GeometrySorting+2 | No attempts yet | 6s | 1024 MB | Judgeable |
| 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. | Hard8 | Binary searchSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | MathNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Монгол ардын үлгэрChoose a subset whose size is at most the total weight of the remaining stones, maximizing the value of that chosen subset. | Hard8 | Dynamic programmingSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | GraphShortest path+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| 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. | Hard8 | Prefix sumDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | Bit manipulationBinary search+2 | No attempts yet | 10s | 256 MB | Judgeable |
| k-Maximum SubarraysPick k disjoint contiguous subarrays of an array with maximum total sum; output only that sum. | Hard8 | Dynamic programmingDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | ArrayString matching+1 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Hard8 | String matchingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | String matchingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Fibonacci NimFind which piles lose the Fibonacci-Nim take-away game and decide the winner of the multi-pile sum game with optimal play. | Hard8 | Game theoryMath+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Maximum Subarray Sum and QueriesGiven an array, answer queries that ask for the maximum subarray sum inside a given index range. | Hard8 | Segment treeDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | Linked listImplementation+2 | No attempts yet | 0.3s | 512 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | ArraySegment tree+2 | No attempts yet | 3.5s | 256 MB | Judgeable |
| 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. | Hard8 | ArrayStack+2 | No attempts yet | 3s | 512 MB | Judgeable |
| 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. | Hard8 | SimulationGreedy+2 | No attempts yet | 3s | 256 MB | Judgeable |
| 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. | Hard8 | ImplementationBinary search+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard8 | Segment treeArray+2 | No attempts yet | 5s | 512 MB | Judgeable |
| 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. | Hard8 | ArrayBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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]. | Hard8 | ArraySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard8 | StackPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Movie-goerChoose a contiguous block of days maximizing the sum of weights of movies that appear exactly once in the block. | Hard8 | ArrayTwo pointers+2 | No attempts yet | 5s | 512 MB | Judgeable |
| 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. | Hard8 | TrieString+2 | No attempts yet | 4s | 512 MB | Judgeable |
| 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. | Hard8 | Two pointersDivide and conquer+2 | No attempts yet | 2.5s | 256 MB | Judgeable |
| 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. | Hard8 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard8 | ArrayImplementation+2 | No attempts yet | 2s | 256 MB | Judgeable |
| 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. | Hard8 | StackArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard8 | ArrayStack+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard9 | Dynamic programmingImplementation+2 | No attempts yet | 10s | 128 MB | Judgeable |
| TreesFor each tree, find the smallest adjacent-difference sum reachable by either keeping the row or swapping that tree with one other tree. | Hard9 | ArrayMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Hard9 | ArrayImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Hard9 | Binary searchGreedy+2 | No attempts yet | 4s | 256 MB | Judgeable |
| 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. | Hard9 | Dynamic programmingDivide and conquer+2 | No attempts yet | 2.5s | 256 MB | Judgeable |
| 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. | Hard9 | SimulationImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard9 | Segment treeArray+2 | No attempts yet | 5s | 512 MB | Judgeable |
| 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. | Hard9 | Binary searchArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Hard9 | Segment treePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Maintaining a SequenceMaintain a sequence under insert, delete, range assign, reverse, range sum, and global maximum subarray queries. | Hard9 | Dynamic programmingImplementation+2 | No attempts yet | 2s | 256 MB | Judgeable |
| 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. | Hard9 | Segment treeDivide and conquer+2 | No attempts yet | 10s | 1024 MB | Judgeable |
| 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. | Hard9 | Segment treeArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Historical ResearchFor each query range, report the maximum over event types t of t times the count of t inside the range. | Hard9 | Divide and conquerArray+2 | No attempts yet | 4s | 512 MB | Judgeable |
| 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. | Hard9 | Divide and conquerTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| OR and QueriesProcess range bitwise-OR updates on an array and count how many positions in a range currently equal a fixed K. | Hard9 | Segment treeBit manipulation+2 | No attempts yet | 1.5s | 256 MB | Judgeable |
| 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. | Hard9 | Segment treeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |