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,179 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Value of a TriangleGiven up to 400 rows of a triangular grid of unit triangles, find the sub-triangle with the largest sum of unit values. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |
| I Hate Number TheoryFor each query interval [L, U] below one million, find the maximum of a score built from prime-factor counts over all subintervals [a, b]. | Medium7 | Number theoryPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Moogle MapsChoose c of h house locations to store so that the average linear interpolation error over all houses is minimized, with endpoints always stored. | Medium7 | Dynamic programmingMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Water?Given an h by w grid of letters and a set of special letters, find the subrectangle with both sides at least m whose fraction of special pixels is maximum, breaking ties by larger area. | Medium7 | Prefix sumBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SpiralOn an N by N grid with blocked fountain cells, find the longest path made of four straight segments turning only right, never revisiting a field. | Medium7 | Brute forceImplementation+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Top 2000Partition a fixed sequence of singles into contiguous blocks, letting each block run under or over M minutes with per-minute penalties, and minimize the total penalty. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MerchantChoose a subset of markets to visit in nondecreasing opening-day order along a river, starting and ending at home, to maximize profits minus asymmetric upstream/downstream fuel costs. | Medium7 | Dynamic programmingSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SailsPlace K sails on each mast (height H) to minimize the total count of same-height sails behind each sail. | Medium7 | GreedySorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Post OfficePlace P post offices in some of V villages on a line so that the sum of each village's distance to its nearest post office is minimized. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| NailsGiven up to 500000 upward triangles on a triangular grid of N nails per side, count the nails covered by at least one triangle. | Medium7 | ArrayPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Optimal Space WayFor each test case, fit a weighted straight line through the plane minimizing the mean squared perpendicular distance from given points, and answer queries that give one point extra weight. | Medium7 | GeometryMath+2 | No attempts yet | 5s | 128 MB | Judgeable |
| RadioactivityFor each pair of radiation radii, count houses not covered by either plant after houses in both zones donate a spare unit. | Medium7 | GeometrySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Your WaysCount monotone lattice paths from (0,0) to (W,H) modulo 2552 for K days, where each day blocks up to 100 unit street/avenue segments with no two blocked segments on a common monotone path. | Medium7 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Arranging HeapsGiven N heaps at increasing positions with weights, merge them into exactly K heaps where each heap moves only downriver, minimizing total weight times distance moved. | Medium7 | Dynamic programmingDivide and conquer+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Jupiter Attacks!Maintain an array under point updates and queries of a polynomial hash over a subarray modulo a prime, printing each hash result. | Medium7 | Segment treePrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Shrinking Inscribed PolygonGiven arc lengths around an inscribed polygon, find the minimum number of vertices to delete so the remaining vertices form a regular polygon, or report -1. | Medium7 | Number theoryMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Land Division TaxSplit a ring of N lots one at a time; each split costs F times the larger resulting piece. Find the minimum total tax. | Medium7 | Dynamic programmingIntervals+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium7 | Two pointersPrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |
| NecklaceGiven a string and a pattern, delete the fewest characters so the pattern no longer appears as a contiguous substring. | Medium7 | Dynamic programmingString matching+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Poker HandsGiven card counts per rank, find the fewest contiguous-rank straights whose unit cards sum to exactly those counts. | Medium7 | GreedyArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Running Away From the BarnFor every node in a weighted tree rooted at node 1, count the descendants within total distance L along the downward path, including the node itself. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Concurrently Balanced StringsGiven K parenthesis strings of length N, count index ranges whose substring is balanced in all K strings at once. | Medium7 | Hash mapPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Haybale RestackingGiven N piles in a circle with current and target amounts of hay, move bales at cost equal to circular distance to reach the target with minimum total work. | Medium7 | GreedyPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Wrong DirectionsGiven a command string of F, L, and R, count the distinct final positions reachable by changing exactly one character to a different one. | Medium7 | SimulationHash map+2 | No attempts yet | 1s | 128 MB | Judgeable |
| OverplantingGiven up to 1000 axis-aligned rectangles, compute the total area of their union. | Medium7 | GeometrySorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow PhotographsGiven a permutation of 1 to N, find the fewest adjacent swaps to reach a rotation of 1..N starting at some cow s, minimized over all s. | Medium7 | ArraySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Generic Cow ProtestsCount the ways to split a sequence into contiguous groups so that every group sum is nonnegative, modulo 1,000,000,009. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Brownie SlicingPartition a grid into A horizontal strips, then cut each strip into B vertical pieces independently, maximizing the minimum piece sum. | Medium7 | Binary searchGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Slowing downFor each cow in order, count how many pastures already occupied by earlier cows lie on the tree path from node 1 to that cow's pasture. | Medium7 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Baric BovineChoose the smallest subset of N pressure readings so the total interpolation-style error stays within E, and report that size plus the least error for it. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The LeprechaunGiven an N x N matrix on a torus, find the contiguous circular run along any row, column, or either diagonal with the largest sum. | Medium7 | ArrayDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium7 | Dynamic programmingDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Bovine Accordion and Banjo OrchestraChoose increasing pairs between two length-N sequences to maximize the sum of A_i*B_j minus the squared sums of each maximal block of unpaired elements on both sides. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Building a New BarnPlace a barn at integer coordinates not used by any cow to minimize the total Manhattan distance to all cows, and count how many such optimal spots exist. | Medium7 | MathSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Gold Balanced LineupGiven N cows each with a K-bit feature ID, find the longest contiguous range where every one of the K features appears the same number of times. | Medium7 | Hash mapPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Calculating Taxi FareGiven a sequence of streets with lengths and per-kilometer times, compute a passenger's fare between two streets using tiered per-kilometer pricing plus night and traffic surcharges. | Medium7 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| AtlantisGiven up to 100 axis-aligned rectangles, compute the area of their union and print it with two decimals. | Medium7 | GeometrySegment tree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| To the MaxFind the contiguous rectangular subregion of an N by N integer matrix with the largest possible sum and print that sum. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Huffman's GreedWe build the optimal binary search tree for weighted key and gap frequencies, minimizing weighted comparison counts. | Medium7 | Dynamic programmingTree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Measuring Problem DifficultyGiven three permutations of the numbers 1 to N, count pairs whose relative order is identical in all three orderings. | Medium7 | SortingDivide and conquer+2 | No attempts yet | 3s | 128 MB | Judgeable |
| ParadeMaintain a list of N perimeter-rotation commands on a 4x4 grid under Q cumulative point updates, printing the resulting grid after each update. | Medium7 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bowling for Numbers++Choose at most k windows of length w, possibly overlapping beyond the row ends, so the sum of the covered pins is as large as possible. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Two SawmillsPlace two extra sawmills along a road so that every tree's downhill haul to the first mill at or below it is minimized. | Medium7 | Dynamic programmingDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GradesInsert Juku into a presentation order to maximize the grades he receives, where grades either reflect project value or reciprocate a prior grade. | Medium7 | GreedyPrefix sum+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| DiscoGiven N disjoint lit intervals on a line of L lamps and M switches that each flip a range, decide if some subset of switches turns every lamp off. | Medium7 | IntervalsGreedy+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Energy CollectionGiven non-overlapping axis-aligned squares, find an axis-aligned collector square that overlaps strictly and is no larger than the cells it collects, maximizing the count. | Medium7 | GeometryBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Maximum Sum of K Non-Overlapping SubmatricesPick exactly K pairwise non-overlapping rectangular submatrices from an N x M matrix to maximize the sum of their elements. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 32 MB | Judgeable |
| NeighboursGiven n peaks on a w by h grid, count non-peak grid points by how many of their four axis directions contain a peak. | Medium7 | SortingHash map+2 | No attempts yet | 2s | 64 MB | Judgeable |
| B-MatrixFind two non-overlapping all-zero rectangles in a binary grid maximizing the total number of cells they cover. | Medium7 | Dynamic programmingMatrix+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Lightning Energy ReportGiven a tree and many path updates that each add a value to every vertex on a path, report the final total at every vertex. | Medium7 | TreePrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |
| One is Good, but Two is BetterGiven an N by M grid of 0, 1, and 2, cover every 2 with two rectangles that avoid 1, minimizing the total area covered. | Medium7 | Brute forcePrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium7 | GeometryTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Better and Faster!Compute a CRC-style bit checksum of a string after each of up to 1e5 character substitutions, fast enough that recomputing from scratch times out. | Medium7 | Bit manipulationMath+1 | No attempts yet | 2s | 512 MB | Judgeable |
| ArtifactGiven n row intervals, choose k consecutive columns and pay the cost to extend each row's interval to cover them, minimizing total added tiles. | Medium7 | Prefix sumSliding window+1 | No attempts yet | 1s | 128 MB | Judgeable |
| I'll Do It TomorrowGiven n jobs with lengths and deadlines, find the longest idle prefix of days, counting from day 1, before some work must begin. | Medium7 | GreedySorting+2 | No attempts yet | 2s | 256 MB | Judgeable |
| ParcelGiven an n by n grid of 0 (arable) and 1 (waste), find the largest all-zero rectangle and print its area. n can be up to 2000. | Medium7 | StackDynamic programming+2 | No attempts yet | 3s | 512 MB | Judgeable |
| 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. | Medium7 | SortingTwo pointers+2 | No attempts yet | 3s | 512 MB | Judgeable |
| 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. | Medium7 | Prefix sumTwo pointers+2 | No attempts yet | 3s | 512 MB | Judgeable |
| MapPartition n populations into m groups to minimize the sum over each group of |value - group median|, where the median can be any value meeting the half-half condition. | Medium7 | Dynamic programmingSorting+2 | No attempts yet | 3s | 128 MB | Judgeable |
| BoxesBoxes stand in a circle with at most n balls total; move balls to neighbors so each box holds at most one, minimizing the number of moves. | Medium7 | GreedyPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Aesthetic TextSplit a sequence of words into lines of length at most m, minimizing the total absolute difference between consecutive line lengths. | Medium7 | Dynamic programmingPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| PalindromesGiven n distinct palindromes, count ordered pairs whose concatenation is also a palindrome, with total length up to 2,000,000. | Medium7 | StringHash map+2 | No attempts yet | 5s | 256 MB | Judgeable |
| WeightsGiven container capacities and weights whose masses form a divisibility chain, maximize how many weights fit. | Medium7 | GreedySorting+2 | No attempts yet | 3s | 128 MB | Judgeable |
| BBBFind the minimum cost to fix a + and - statement so the balance starts at p, never goes negative, and ends at q, using character flips and rotations. | Medium7 | GreedyPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Multiset Permutation RankGiven one permutation of a multiset, compute its lexicographic rank among all distinct permutations, modulo m. | Medium7 | CombinatoricsMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Ticket InspectorChoose k of the n-1 travel segments so that the total number of passengers present on at least one chosen segment is maximized. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium7 | Prefix sumTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Letter Frequency DifferencePick any contiguous fragment of a lowercase word to maximize the gap between its most and least frequent letters. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| CloakroomFor each query (m, k, s), decide whether some items with a_i <= m and b_i > m+s have values summing to exactly k. | Medium7 | Dynamic programmingSorting+2 | No attempts yet | 2s | 128 MB | Judgeable |
| BanjoPick two separate one-minute intervals to maximize the number of people present for at least one full minute. | Medium7 | ArraySorting+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Alien InvasionFind the maximum total residents the aliens can abduct, given that a warning from an attacked city reaches city k one day later per unit distance. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SunsetsFor each cell of an n x n grid, output the tallest height among all cells within Manhattan distance k. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium7 | Sliding windowStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Land SwindleFor each meadow square choose at most one rectangle ending there, maximize the total perimeter, where each rectangle must contain only meadow squares. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| TowerPartition the sequence of brick widths into consecutive blocks so that block sums do not increase from bottom to top, maximizing the number of blocks. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sunset Views 2For each point on an n by n grid, take the maximum building height within Manhattan distance k, then sum all these maxima. | Medium7 | ArrayPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Guessing GameFind the largest prefix of interval parity answers that stays consistent with some 0/1 sequence of length one billion. | Medium7 | Union-findPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Bridge PillarsPick a modulus m above 1 that keeps the largest group of pillar heights sharing one remainder, with ties broken toward the larger m. | Medium7 | Number theoryPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| Weights and ScalesPlace one gray weight on the empty pan, then repeatedly merge each balanced scale in the nested tower, and report the fewest weights that can remain. | Medium7 | Prefix sumHash map | No attempts yet | 1s | 128 MB | Judgeable |
| The StructureA tower splits the top load equally down its columns, and after each strength update you report how many queued visitors from the front it can hold. | Medium7 | Segment treePrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| RoundupCount the axis-aligned squares of side at least 2 whose border cells are all 1 in an n by n binary grid. | Medium7 | Prefix sumMatrix+1 | No attempts yet | 1s | 128 MB | Judgeable |
| SpringsPick one integer target length for the k shortest springs to minimize the total triangular stretching cost. | Medium7 | Prefix sumBinary search+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ABCFind the length of the longest nondecreasing common subsequence of two strings over a, b, and c. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium7 | Prefix sumTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| GC-RatioFind the contiguous segment of length at least L with the largest share of ones, breaking ties by shorter length then earlier start. | Medium7 | Binary searchPrefix sum | No attempts yet | 2s | 128 MB | Judgeable |
| DeliveryJim starts at 0, carries at most one parcel at a time between points on a road, and returns to 0 after delivering all parcels over the shortest total distance. | Medium7 | GreedySorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| TokensFor each token with given length and lookahead, compute how far back its text affects earlier token boundaries. | Medium7 | Two pointersPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| Flight Boarding OptimizationYou split the rows into k contiguous zones and order their boarding phases, keeping queue order inside each zone, to minimize total boarding difficulty. | Medium7 | Dynamic programmingIntervals+1 | No attempts yet | 2s | 256 MB | Judgeable |
| International EventFind the minimum distance for a robot starting and ending at A to move every flag along a line from its old pole to a pole requesting that nation. | Medium7 | GreedyPrefix sum+1 | No attempts yet | 5s | 128 MB | Judgeable |
| Join two kingdomsTwo trees with up to 40000 nodes each are joined by one uniformly random cross edge, and you must output the expected diameter of the combined tree. | Medium7 | TreeSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| No ChangePay the ordered purchases with distinct coins, each covering one consecutive group within its value, to maximize unused value, or print -1. | Medium7 | Dynamic programmingBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Hack ProtectionCount the subarrays of the given array whose bitwise XOR equals their bitwise AND. | Medium7 | Bit manipulationPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Shortest Subsequence With Sum at Least XFind the length of the shortest contiguous subarray whose sum is at least X, or report -1 when none exists. | Medium7 | Prefix sumQueue | No attempts yet | 3s | 256 MB | Judgeable |
| Super AntsAn ant on a grid cell collects its value and spawns clones along eight rays within the remaining time, and you compute the total score modulo 1e9+7. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Fair PhotographyAfter sorting cows by position, find the widest contiguous group containing at least K breeds with each present breed appearing equally often. | Medium7 | Prefix sumHash map | No attempts yet | 1s | 128 MB | Judgeable |
| Split the sequenceSplit the sequence into k+1 contiguous parts so the total product score from the cuts is maximal, and print the score with one optimal cut list. | Medium7 | Dynamic programmingDivide and conquer+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Early Exam EvacuationEach of M writers seated in an N-row auditorium exits front or back to minimize passing plus crowding cost. | Medium7 | Dynamic programmingSorting+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Around the worldFor each plane range, find the fewest refueling landings to circle all airports from the best start, or report impossible. | Medium7 | GreedyPrefix sum+1 | No attempts yet | 5s | 24 MB | Judgeable |
| CarpetFind the area of the largest subrectangle of a flawed carpet grid that holds at most one flaw. | Medium7 | StackPrefix sum+1 | No attempts yet | 4s | 256 MB | Judgeable |
| Gold MinesPick an axis-aligned rectangle over weighted points to maximize the sum of enclosed weights. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 3s | 256 MB | Judgeable |