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,178 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Cow RaceTwo cows run the same total time in constant-speed segments; count how many times the lead switches or is re-taken after a tie. | Medium5 | SimulationImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| TypoGiven a bracket string with at most one typo, count how many single-character flips turn it into a valid balanced bracket string. | Medium5 | StringImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BookshelfPartition the books in order into shelves whose widths sum to at most L, minimizing the total of each shelf's maximum height. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Pasture WalkingGiven a weighted tree with N vertices and Q queries, find the path length between each queried pair of vertices. | Medium5 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Switching LightsMaintain a binary array of N lights under M range-toggle and range-count operations, and print each query result. | Medium5 | Segment treeArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Tallest CowGiven the tallest cow's height and index plus pairs where cow a sees cow b, find each cow's maximum possible height consistent with all observations. | Medium5 | GreedyPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Wine Trading in GergoviaGiven net wine demands along a line summing to zero, find the minimum total transport cost (one unit per bottle per adjacent step). | Medium5 | GreedyPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Quantum OperationsCompute the tensor product of several integer matrices and report its element extremes plus maximum and minimum row and column sums. | Medium5 | ImplementationMatrix+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Maximum DamageOn a grid with obstacles, orcs, and blank cells, pick at most T blank cells as stations so the total number of orcs within Manhattan distance R is maximized. | Medium5 | Prefix sumBrute force+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Tax SystemEach client's income is taxed through N progressive brackets with given widths and rates; compute the total tax for M clients, printed to two decimals. | Medium5 | Prefix sumBinary search+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Polygon AreaGiven a grid-aligned orthogonally convex polygon as a string of unit moves, compute its area. | Medium5 | GeometryImplementation+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| MetroGiven the intervals between adjacent trains, find the wait time for each train so every gap becomes M with the smallest total waiting. | Medium5 | GreedyMath+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| Ship JourneyFind the latest whole-minute departure so the ship reaches 100 km strictly before the deadline, minimizing travel time. | Medium5 | SimulationBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Catching FishGiven up to 100 fish on a large grid and a fixed net perimeter, find the placement of the net that covers the most fish. | Medium5 | Brute forcePrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| FactoryGiven two orderings of the same N numbers, count pairs of connecting cables that cross when drawn as straight lines. | Medium5 | SortingPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| RailwayGiven a weighted tree, compute the total weight of the unique path between each queried pair of cities. | Medium5 | TreePrefix sum+1 | No attempts yet | 1s | 32 MB | Judgeable |
| PearlsGiven demand and price per pearl for classes in increasing quality order, find the cheapest way to buy all pearls when each class's order may be upgraded to a higher class, paying 10 extra pearls' worth per purchase. | Medium5 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| k-Even-Sum SequenceChange the fewest elements so that every contiguous block of length k in the sequence has an even sum. | Medium5 | GreedyMath+2 | No attempts yet | 1s | 256 MB | Judgeable |
| IslandGiven the edge lengths of a cycle, find the maximum over all pairs of towns of the shorter of the two arc distances. | Medium5 | Two pointersPrefix sum+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Building BlocksFind the minimum number of add/remove block moves so that some k consecutive columns end up with equal height. | Medium5 | Sliding windowPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Rectangles 2Count axis-aligned rectangles with vertices on grid points of an n x m grid whose perimeter is at least p. | Medium5 | MathCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| EncyclopediaGiven a stack of n pages and n sleeves, swap adjacent elements to make the two types alternate, and output the minimum number of swaps. | Medium5 | GreedyArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The TravelerCompute the height and width of the smallest axis-aligned rectangle containing a walk given in repeated direction blocks. | Medium5 | SimulationPrefix sum+1 | No attempts yet | 1s | 512 MB | Judgeable |
| MatchesFlip the fewest matches in a row so fire lit at the left end spreads through every neighboring pair. | Medium5 | Dynamic programmingPrefix sum | No attempts yet | 1s | 512 MB | Judgeable |
| MerchantBuy in one city and sell in another along a line to maximize selling price minus buying price minus travel cost. | Medium5 | GreedyPrefix sum | No attempts yet | 1s | 512 MB | Judgeable |
| Telephone ExchangePick an integer tower height so the fees from houses fully covered by the circle exceed the height-dependent maintenance cost by as much as possible. | Medium5 | GeometrySorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| CitiesCount for each city on a directed line how many other cities are reachable through one-way and two-way roads. | Medium5 | ArrayPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| Paper StripFind the longest contiguous block of numbers that adds up to exactly s, or print BRAK when none exists. | Medium5 | Hash mapPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| Equalizing Water in GlassesGiven the water levels in n adjacent glasses, find the fewest pours between neighbors that make all levels equal. | Medium5 | GreedyPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| The BoardFind the longest string of zeros followed by ones that appears as a subsequence of both given binary sequences. | Medium5 | GreedyTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| TowerEach resident climbs the steps from the bottom and stops before the first step whose height reaches their own. | Medium5 | Binary searchPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| KonkotenacjaCount the ways to split the word into nonempty pieces joined by the literal separator kot, modulo 1000000007. | Medium5 | Dynamic programmingPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| The Tired Traveling SalesmanFind the integer point off all customer sites that minimizes total Manhattan distance and count how many such points tie. | Medium5 | SortingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Pretty good numbersCount the integers in each interval whose absolute gap between the proper-divisor sum and the number is within the limit. | Medium5 | Number theorySorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| LightsYou press switches that flip the rectangle from the origin to the switch and need the fewest presses to turn every bulb on. | Medium5 | GreedyPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| Stacking BlocksReshape both towers into the V-shaped skyline with center height h at the lowest total cost of added and removed blocks. | Medium5 | SortingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The Lazy CowChoose the cell whose Manhattan diamond of radius K holds the most grass and output that sum. | Medium5 | Prefix sumMatrix | No attempts yet | 1s | 128 MB | Judgeable |
| Fair PhotographyAfter sorting cows by position, find the widest interval with equal numbers of G and H cows, where single-breed intervals also count. | Medium5 | Prefix sumHash map+1 | No attempts yet | 1s | 128 MB | Judgeable |
| VacationFrom a start city on a line with a fixed day budget where each move or city visit costs one day, pick the contiguous block with the most attractions. | Medium5 | Two pointersPrefix sum+1 | No attempts yet | 5s | 64 MB | Judgeable |
| Fuleco and the AntGiven positions A and B and a U/D string encoding depth changes along a tree walk, output the tree distance between the two forks. | Medium5 | TreePrefix sum+1 | No attempts yet | 1s | 64 MB | Judgeable |
| Andres IniestaYou remove up to K obstacles and choose a standing cell to maximize visible cells in its row and column. | Medium5 | Brute forcePrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Salad BarFind the longest contiguous block of apples and oranges where oranges never fall behind apples when added from either end. | Medium5 | Prefix sumStack+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Market ShoppingYou choose exactly k prices per query to maximize the odd total, printing -1 when no odd sum exists. | Medium5 | GreedySorting+1 | No attempts yet | 10s | 256 MB | Judgeable |
| DebtFor every group size M, choose M loans to minimize M times the largest chosen loan minus their sum, and output the total of these minima. | Medium5 | SortingPrefix sum | No attempts yet | 1s | 256 MB | Judgeable |
| Travel CardGiven daily bus and train ride counts, compute the cheapest mix of single fares and 1, 7, and 30 day bus and travel passes. | Medium5 | Dynamic programmingPrefix sum | No attempts yet | 1s | 256 MB | Judgeable |
| Cent SavingsSplit up to 2000 item prices in order into at most d+1 consecutive groups so the sum of each group rounded to the nearest 10 cents is smallest. | Medium5 | Dynamic programmingPrefix sum | No attempts yet | 5s | 512 MB | Judgeable |
| Ssari and Bird's PyramidCount how many times a given letter appears in a requested pyramid row filled by repeating a word in alternating directions. | Medium5 | MathPrefix sum | No attempts yet | 1s | 256 MB | Judgeable |
| WindowFind the largest interior grid-aligned square whose border runs only along domino edges and report its size and top-left corner. | Medium5 | Prefix sumBrute force | No attempts yet | 8s | 256 MB | Judgeable |
| Color BallsFor each ball, add up the sizes of all strictly smaller balls with a different color. | Medium5 | SortingPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Palindrome??Answer up to a million queries asking whether a subarray of the given number sequence reads the same forward and backward. | Medium5 | String matchingPrefix sum | No attempts yet | 1s | 256 MB | Judgeable |
| Box BettingThe driver picks a random contiguous run of boxes, and the program reports how often its item sum lands below L, within L to U, or above U. | Medium5 | Prefix sumBinary search | No attempts yet | 1s | 256 MB | Judgeable |
| Alphabet on a CircleStarting at a, walk the 26-letter circle with direction flips at given points and count how often the queried letter occurs in the first n spoken letters. | Medium5 | MathPrefix sum+1 | No attempts yet | 2s | 64 MB | Judgeable |
| Happy NumbersFind the smallest start of K consecutive integers with exactly L numbers that are at most M or prime, or output -1. | Medium5 | Number theoryPrefix sum+1 | No attempts yet | 0.5s | 64 MB | Judgeable |
| Load BalancingPlace one vertical and one horizontal fence between the odd-coordinate cow positions to minimize the largest cow count in any of the four regions. | Medium5 | SortingPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Cleaning the Club Room!Pick exactly M evenings to reset dirt to zero so the sum of daily visitors times dirt since the last cleaning is smallest. | Medium5 | Dynamic programmingPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| gCube (Large)Answer many range queries asking for the geometric mean of array values with nine digits after the decimal point. | Medium5 | Prefix sumMath | No attempts yet | 5s | 512 MB | Judgeable |
| Up and Down (Large)Find the fewest adjacent swaps that turn the sequence into one that rises to a peak and then falls. | Medium5 | GreedyPrefix sum | No attempts yet | 5s | 512 MB | Judgeable |
| Password Problem (Large)Choose how many typed characters to keep or erase to minimize the expected keystrokes to finish a password with known per-character correctness odds. | Medium5 | ProbabilityPrefix sum+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Irregular Cakes (Large Input)Find the vertical cut positions that split the region between two polylines into G slices of equal area. | Medium5 | GeometryBinary search+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Theme Park Roller CoasterSimulate R rides where groups at the front board until the next group cannot fit, then return to the back; report total earnings. | Medium5 | QueueSimulation+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Traffic (Small)Given a tree and Q tickets, count how many tickets use each edge along the unique path, then report the edge with the largest count (smallest station pair on ties). | Medium5 | TreePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Birthday PresentsPick a subset of presents whose price range is below D, maximizing total satisfaction. | Medium5 | SortingSliding window+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Centipede legsGiven n and m notes, choose left and right leg counts summing to n, both at least 1, maximizing how many notes have l_i <= left and r_i <= right, breaking ties by smallest left count. | Medium5 | MathPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Distinct rational numbersCount distinct values of a/b with 0 <= a <= b <= N, i.e. fractions in [0,1] with reduced denominator at most N. | Medium5 | MathNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| WindowPick a uniformly random axis-aligned subrectangle of an H by W grid; find the expected number of cells times 9, modulo 1e9+7. | Medium5 | MathCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Lucky TicketsCount digit strings of length 2N whose first N digits sum to the same value as the last N digits, modulo 1e9+7. | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ResortChoose one-day, 3-day, and 5-day passes over a vacation with blocked days so every open day is covered at minimum cost, where 3 coupons buy a free one-day pass. | Medium5 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Water PumpPlace one pump in a cell, let water drain toward it from both sides, and find the cell that removes the most water. | Medium5 | ArrayPrefix sum | No attempts yet | 2s | 512 MB | Judgeable |
| Isosceles Cube TriangleGiven column heights, find the largest h such that some 2h-1 consecutive columns can all be reduced to the shape 1,2,...,h,...,2,1. | Medium5 | ArrayBrute force+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Mário's LockersGiven the positions of L free lockers, find the minimum number of swaps to gather N of them into consecutive positions. | Medium5 | Sliding windowPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Making the Array PalindromicMerge adjacent elements (each merge sums them) so the resulting array reads the same forwards and backwards, using the fewest merges. All values are positive. | Medium5 | Two pointersGreedy+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Binomial coefficient queriesGiven M pairs N and K, print the binomial coefficient C(N, K) modulo 1,000,000,007. | Medium5 | CombinatoricsMath+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Reading ListTotal lifted books over a sequence of assignments, where each assigned book moves to the top of the tower. | Medium5 | ArraySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Banknotes and RouletteSplit banknotes so the two equal-sum groups leave the smallest leftover, then add half of twice that leftover to each person's total. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Score of a SubsequenceFind the maximum over all contiguous subarrays of the weighted sum where the k-th element from the subarray start contributes k times its value. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Segments greater than KCount the contiguous subarrays whose sum exceeds k. | Medium5 | Two pointersPrefix sum | No attempts yet | 2s | 512 MB | Judgeable |
| Company Culture 2Given a tree of boss relations, apply subtree-wide praise additions in real time and answer point total queries. | Medium5 | TreeDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Company Culture 3Employees sit in a rooted tree. A praise of w given to employee i from a subordinate adds w to i and every ancestor up to the president; type 2 queries ask an employee's running total. | Medium5 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ParetoChoose k accounts maximizing B minus A, where A = 100k/N and B is their share of all money as a percent. | Medium5 | GreedySorting+2 | No attempts yet | 1s | 64 MB | Judgeable |
| RainwaterGiven stack heights across a 2D world, compute the total rainwater trapped between the blocks after heavy rain. | Medium5 | ArrayTwo pointers+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Circular HighwayCount starting stations on a circular road where buying all fuel and driving forward never empties the tank before returning. | Medium5 | Prefix sumGreedy+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Rectangles and QueriesGiven an N by N matrix with values at most 10, answer many rectangle queries, each asking how many distinct integers appear inside the submatrix. | Medium5 | Prefix sumMatrix+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hamming distance queriesGiven binary strings a and b, answer queries asking for the Hamming distance between a substring of a and a substring of b. | Medium5 | Prefix sumString+2 | No attempts yet | 6s | 512 MB | Judgeable |
| Building a ranchGiven an M by N grid with trees and rocks as obstacles, find the side length of the largest square subgrid that contains no obstacle. | Medium5 | Dynamic programmingMatrix+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Stone Skipping (SUJEBI)For each step size d, sum the cells at multiples of d and pick the d with the largest sum, printing 0 0 if that sum is not positive. | Medium5 | MathBrute force+2 | No attempts yet | 2s | 512 MB | Judgeable |
| CuriosityFor each query [a, b], find the primes in the range in order and compute an alternating sum that triples odd-indexed primes. | Medium5 | Number theoryPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Flea MarketEach person has a supply or demand of fleas at unit-distance positions; find the minimum total delivery cost. | Medium5 | GreedyPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Rock Paper Scissors MachineGiven two RPS strings, choose where in the opponent's longer string to start matching your shorter string and report the most wins. | Medium5 | StringString matching+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Purple RainGiven a string of R and B characters, find the contiguous block maximizing |r - b|, breaking ties by westernmost start then westernmost end. | Medium5 | ArrayGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Candy SalesFor each day j, print the minimum over all i at most j of w_i + (j - i). | Medium5 | ArrayPrefix sum+1 | No attempts yet | 6s | 512 MB | Judgeable |
| DebugEach call increments every index divisible by the given jump; answer range-sum queries over the resulting array. | Medium5 | ArrayMath+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Robot Energy Source OrderReorder n energy sources, each with acceleration a_i and duration s_i, to maximize total distance, and print the gain over the given order. | Medium5 | SortingGreedy+2 | No attempts yet | 0.2s | 128 MB | Judgeable |
| Trunk RoadsChoose one horizontal and one vertical line in an H by W grid to minimize the total distance residents at each cell pay to the nearer chosen line. | Medium5 | Brute forcePrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Art ExhibitionChoose a subset of artworks maximizing the sum of values minus the difference between the largest and smallest sizes in the subset. | Medium5 | SortingPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Maximum range sum? 1Maintain an array under point updates. For each range query, find the maximum of U times a subarray sum plus V times its length over all subarrays inside the range. | Medium5 | ArrayBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cute RyanGiven a row of N dolls labeled 1 or 2, find the length of the shortest contiguous block containing at least K dolls labeled 1. | Medium5 | Two pointersSliding window+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Roasting Emma is a barista tooGiven a weighted tree, compute for every vertex the sum of shortest distances to all other vertices. | Medium5 | TreeDFS+2 | No attempts yet | 1.5s | 128 MB | Judgeable |
| Rest StopsBessie rests at grass stops along a trail and must never fall behind Farmer John; maximize total tastiness of eaten grass. | Medium5 | GreedySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| *Light*Young*Woo*Given N lights that each illuminate a 90-degree upward sector, count for each query point how many sectors contain it. | Medium5 | GeometryPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| DollsGiven N numbers in a fixed order, find a contiguous segment of at least K numbers whose standard deviation is minimized, and output that standard deviation. | Medium5 | Brute forcePrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |