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 results3,779 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Star FruitGiven summer length N, growth time T, C plots, and price P, compute the maximum money earnable by planting and replanting each plot as often as possible. | Easy3 | GreedyMath+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Hamster BallTape can seal a ball only if its tape needed is at most the radius; each ball of radius s costs 2*pi*s, so pick sizes with the cheapest cost per ball. | Easy3 | GreedySorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Climbing StairsGiven the required walk length n, the desk height r, and the office height k, find the minimum total steps walked in a day while starting and ending on the ground floor. | Easy3 | MathImplementation+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Price EvaluationGiven property prices and a list of m property names where some entries are unknown, find the minimum and maximum possible total price. | Easy3 | ImplementationGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Mountain RangesGiven non-decreasing viewpoint altitudes along a trail, find the length of the longest run where each consecutive altitude increase is at most X, starting anywhere. | Easy3 | ArrayTwo pointers+2 | No attempts yet | 0.1s | 512 MB | Judgeable |
| ZOAC 2A disk holds the 26 uppercase letters in a circle, and an arrow starts at 'A'. Find the minimum total rotations needed to print a given string in order. | Easy3 | ImplementationGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Boxing Day Football AnalysisGiven the order of N goals scored by two teams, report the final score, the number of tied scores reached during the match, and the longest run of successive goals that flipped a deficit into a lead. | Easy3 | SimulationImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| BiodiversityGiven the species names of N animals, print the species that appears more times than all other species combined, or NONE. | Easy3 | Hash mapImplementation+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Word ProcessorFormat N words into lines of at most K characters using the greedy first-fit rule, then print the result. | Easy3 | SimulationImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Military ServiceEach soldier works at most K consecutive months then rests one month; find the largest number of soldiers that can be guaranteed on duty in every month. | Easy3 | MathGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| FeedbackBuild a strictly increasing length-N sequence with values at most 1000, second element 2, and last element prime. | Easy3 | MathNumber theory+2 | No attempts yet | 1s | 512 MB | Judgeable |
| SortingGiven a list of question difficulties, determine the minimum number of adjacent swaps needed to sort them into increasing order. | Easy3 | SortingGreedy+1 | No attempts yet | 1s | 512 MB | Judgeable |
| LunchBoxGiven N lunch boxes and each school's request ki, choose schools to satisfy fully (all ki boxes or none) so the count of served schools is maximized. | Easy3 | GreedySorting+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Big Round TableMasha sits at a round table of n seats and makes exactly k swaps with a left or right neighbor; count the seats she could occupy at the end. | Easy3 | MathGreedy+1 | No attempts yet | 1s | 512 MB | Judgeable |
| SapsanGiven a row of n seats split into n/2 adjacent pairs, find the largest number of occupied seats so that exactly half the seated people sit next to an occupied neighbor. | Easy3 | MathGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Attractive FlowersGiven the stock of each flower type, pick an odd count from each type so the total is odd and as large as possible. | Easy3 | GreedyMath+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Maximum ProductSplit the array after one index so the product of the two part sums is maximized, and print that index. | Easy3 | Prefix sumArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Room NumberGiven digit prices and a budget, find the largest possible room number (no leading zero unless it's just 0) that can be bought within the budget. | Medium4 | GreedyString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Line UpReconstruct a line of N people (heights 1..N) given for each height how many taller people stand to its left, using reverse insertion. | Medium4 | ArrayGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| AppointmentsGiven N pairs of appointment and arrival times, find how many integer shifts T minimize the total waiting time, which reduces to counting optimal medians of the differences. | Medium4 | SortingMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Minimum Spanning TreeCompute the total edge weight of a minimum spanning tree for a weighted undirected graph with up to 10,000 vertices and 100,000 edges, allowing negative weights. | Medium4 | Minimum spanning treeUnion-find+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Make a PalindromeRearrange the letters of a given uppercase string into the lexicographically smallest palindrome, or report it is impossible. | Medium4 | StringGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Online Egg SalesGiven N eggs and M customers' maximum bid prices, pick the selling price (lowest if tied) that maximizes total revenue when all customers bidding at least that price buy an egg, capped at N sales. | Medium4 | SortingGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Time ManagementGiven tasks with durations and deadlines, find the latest single start time so that all tasks scheduled back to back meet their deadlines, or report -1 if impossible. | Medium4 | GreedySorting+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Word MathAssign distinct digits 0-9 to letters so that the sum of several words, read as base-10 numbers, is as large as possible. | Medium4 | GreedyMath+1 | No attempts yet | 2s | 256 MB | Judgeable |
| PolyominoCover every run of X cells with 2-cell (BB) and 4-cell (AAAA) blocks and print the lexicographically smallest resulting board, or -1 if some run has odd length. | Medium4 | GreedyString+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Lecture RoomsGiven N lecture intervals, compute the minimum number of rooms needed so no room hosts overlapping lectures, treating touching endpoints as non-overlapping. | Medium4 | GreedySorting+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Cable DonationGiven an adjacency matrix of cable lengths between rooms encoded as letters, find a minimum spanning tree and output the maximum total cable length that can be donated, or -1 if the rooms cannot all be connected. | Medium4 | Minimum spanning treeGraph+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Number DecompositionGiven N up to 1,000,000, decompose it into nonnegative integers whose sum is N to maximize the product, then output that product mod 10007. | Medium4 | MathGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| FlippingGiven a binary string, find the minimum number of contiguous-segment flips needed to make all characters equal. | Medium4 | StringGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Triangle BuilderGiven N straw lengths, pick three that form a triangle with the largest possible perimeter, or report -1 if none exist. | Medium4 | SortingGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Building Rest StopsGiven existing rest stops on a highway, place M new integer-position stops to minimize the longest gap between consecutive stops, found via binary search. | Medium4 | Binary searchGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Selling GoodsGiven each buyer's max price and delivery cost, choose a sale price (ties broken by lowest) that maximizes total profit summed over buyers who purchase profitably. | Medium4 | Brute forceSorting+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Police StationsGiven a directed graph and per-city build costs, find strongly connected components and sum the minimum cost city in each component. | Medium4 | GraphDFS+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Document SearchGiven a document and a word, find the maximum number of non-overlapping occurrences of the word within the document. | Medium4 | String matchingGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Cable CuttingGiven K cable lengths, binary search the maximum integer cut length so that summing floor(length/cut) over all cables reaches at least N pieces. | Medium4 | Binary searchGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Overlapping SegmentsGiven N line segments on a number line, compute the maximum number of segments that overlap at any single point, not counting endpoint-only contacts. | Medium4 | IntervalsSorting+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Stack SequenceDetermine if a target permutation of 1 to n can be produced by a stack pushing values in increasing order, and output the push/pop sequence if possible. | Medium4 | StackSimulation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Network ConnectionGiven N computers and M weighted possible connections, compute the minimum total cost of edges to connect all computers into one network (minimum spanning tree). | Medium4 | Minimum spanning treeUnion-find+1 | No attempts yet | 2s | 256 MB | Judgeable |
| New EmployeesGiven N applicants ranked by two criteria, count applicants not dominated in both ranks by any other applicant (classic sort plus max-suffix pattern). | Medium4 | SortingGreedy | No attempts yet | 2s | 256 MB | Judgeable |
| CoinsGiven limited counts of coins worth 1, 5, 10, and 25 cents, find the combination summing to exactly X cents that uses the maximum total number of coins. | Medium4 | GreedyBrute force+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Router InstallationGiven house coordinates, place C routers among them to maximize the minimum pairwise distance between chosen routers. | Medium4 | Binary searchGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Post OfficeGiven villages with positions and populations on a line, find the point minimizing total weighted distance, choosing the smallest position on ties. | Medium4 | SortingPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Cake DeliveryCompute the minimum total grid-walk distance to visit N customers in fixed order, where reaching any of the 4 neighbors of a customer point counts as delivery. | Medium4 | GreedyMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Kimchi DeliveryGiven N cities on a line and a starting point, find the order of visiting all cities minimizing the sum of arrival times. | Medium4 | GreedyDynamic programming+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Barn AssignmentGiven each cow's list of acceptable stalls, find the maximum number of cows that can be matched to distinct stalls using bipartite matching. | Medium4 | GraphGreedy | No attempts yet | 2s | 128 MB | Judgeable |
| SensorsGiven N sensor coordinates and up to K interval-shaped concentrators, find the minimum total interval length needed to cover all sensors. | Medium4 | SortingGreedy | No attempts yet | 2s | 128 MB | Judgeable |
| Choosing CondosCount condos that are Pareto-optimal, having no other condo that is both closer to the beach and cheaper. | Medium4 | SortingGreedy | No attempts yet | 2s | 128 MB | Judgeable |
| Find the Binary NumberGiven N, L, and I, output the I-th binary string of length N (with at most L ones) in increasing numeric order. | Medium4 | CombinatoricsBinary search+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Building a TreeFind a spanning tree rooted at R that minimizes the sum of parent degrees over all non-root vertices, using a BFS-like greedy shortest path with degree as edge weight. | Medium4 | Shortest pathGraph+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Guitar LessonSplit an ordered array into M contiguous groups so the maximum group sum is as small as possible, using binary search on the answer. | Medium4 | Binary searchGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Maximum DistanceGiven up to 50,000 points, compute the maximum L1 (Manhattan) distance between any two of them. | Medium4 | MathGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Three Numbers, Two MsGiven n integers, pick three to maximize 3 times (median minus mean), which reduces to sorting and checking min/max extremes. | Medium4 | SortingGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Smallest Unmeasurable WeightGiven N integer weights usable only on one pan, find the smallest positive integer amount that cannot be formed as a subset sum. | Medium4 | GreedySorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| PasswordGiven integer A, find the nearest smaller and nearest larger integers with the same popcount as A, using bit manipulation, or print 0 if none exists. | Medium4 | Bit manipulationMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Two Liquids Closest to ZeroGiven a sorted array, find two distinct numbers whose sum is closest to zero using a two-pointer sweep. | Medium4 | Two pointersArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Street TreesGiven sorted tree positions, find the minimum number of trees to insert so all consecutive gaps equal the GCD of all gap sizes. | Medium4 | MathNumber theory+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Budget AllocationGiven budget requests and a total cap, find the maximum integer cap value such that capping requests at that value keeps the total within budget. | Medium4 | Binary searchGreedy | No attempts yet | 1s | 128 MB | Judgeable |
| Eating PancakesGiven a box A×B×C and D unit-thickness slices removed one dimension at a time, maximize the remaining volume by choosing which dimension to shrink each cut. | Medium4 | GreedyMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Fire EnginesGiven sorted positions of pumps and fire engines on a line, assign each engine a distinct pump to minimize total distance connected. | Medium4 | GreedyDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Amusement ParkGiven ride schedules with 10-minute buffers before and after each, find the longest free interval within 10:00-22:00 where no ride's blocked window overlaps. | Medium4 | IntervalsSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Stacking Colored PaperGiven N rectangles with allowed 90-degree rotation, find the longest chain where each sheet fits entirely inside the previous one. | Medium4 | Dynamic programmingSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Maximum Number of Noncrossing Circle ChordsGiven up to 50 chords on 100 circle points with distinct endpoints, find the maximum subset of chords with no two crossing. | Medium4 | Dynamic programmingIntervals+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Next Greater NumberGiven a large number as a digit string, find the smallest permutation of its digits that is greater than it, or report BIGGEST if none exists. | Medium4 | StringGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Pancake FlippingSort a stack of N distinct pancakes into increasing order from top using prefix reversals, within a bound of 2N-3 flips. | Medium4 | GreedySimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Number PlayFor each N, greedily factor it into digits 9 down to 2 to find the minimum digit count of a number whose digits multiply to N, or report -1 if impossible. | Medium4 | GreedyMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ChainsGiven lengths of N chains, find the minimum number of links to open and close so that all chains merge into a single chain. | Medium4 | GreedySorting+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Tree CuttingBinary search for the maximum saw height H so that trimming all trees above H yields at least M meters of wood total. | Medium4 | Binary searchGreedy | No attempts yet | 1s | 256 MB | Judgeable |
| Make the Largest NumberGiven an N-digit number, remove exactly K digits while keeping relative order to form the largest possible remaining number. | Medium4 | StackGreedy | No attempts yet | 1s | 128 MB | Judgeable |
| Apple Catching GameMove a fixed-size basket left or right along N cells to catch a sequence of falling apples with minimum total movement distance. | Medium4 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| A Library at HomeFind the minimum number of top-moves needed so a pile of numbered books ends up sorted 1..N from top to bottom. | Medium4 | GreedyArray | No attempts yet | 1s | 128 MB | Judgeable |
| Graphics QuizFor each of 5 grades, find the longest contiguous run of desks where at least one student has that grade, then output the best length and the smallest grade achieving it. | Medium4 | ArraySliding window+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Kayaks and the Strong WindGiven broken and spare-carrying teams in a line, assign each spare kayak to an adjacent broken team to minimize the number of teams left unable to start. | Medium4 | GreedyBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Three KangaroosGiven three sorted integer positions, compute the maximum number of jumps where an outer point can move to any free integer strictly between the other two. | Medium4 | MathGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Next Greater Number with the Same DigitsGiven an integer, find the smallest number larger than it using exactly the same multiset of digits, or print 0 if impossible. | Medium4 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Choosing a NameGiven even integers and a range [A,B], find an odd integer in that range maximizing the minimum distance to all given even values. | Medium4 | ArrayGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| DownloadGiven download times and playback durations of sequential song pieces, compute the earliest start time so playback never stalls waiting for a piece. | Medium4 | GreedyPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Multi-key SortingGiven a sequence of stable column sorts, output the shortest equivalent sequence by keeping only the last occurrence of each column value in the order that determines the final effect. | Medium4 | ArrayGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| The RiddleFind the minimum prefix length of a coin sequence so that all values from 1 to K are achievable as subset sums, using the classic greedy reachable-range extension, or report -1. | Medium4 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Reducing a SequenceGiven a sequence, find the minimum total cost of repeatedly merging adjacent elements where cost equals the max of the pair, until one element remains. | Medium4 | GreedyArray | No attempts yet | 1s | 128 MB | Judgeable |
| Division ExpressionGiven a left-to-right division expression of n positive integers, decide if some parenthesization yields an integer value, which reduces to checking if x1 times the product of x3..xn is divisible by x2. | Medium4 | MathNumber theory+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ClassGiven n students and an r by c grid of desks, find the maximum achievable value k such that some row and some column can each have k occupied desks. | Medium4 | MathGreedy+1 | No attempts yet | 3s | 256 MB | Judgeable |
| The Bird TreeGiven a reduced fraction, reconstruct its path of L/R moves in the Stern-Brocot style Bird tree using a Euclidean-like process. | Medium4 | MathGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| MatchsticksGiven a number of matchsticks, find the smallest and largest positive numbers (no leading zero) that can be formed using exactly that many matchsticks based on per-digit costs. | Medium4 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| SongsGiven songs with lengths and play frequencies, sort them by length-to-frequency ratio (stable on ties) to minimize expected access time and report the song at a queried position. | Medium4 | GreedySorting | No attempts yet | 1s | 128 MB | Judgeable |
| Slim SpanGiven a weighted graph, find the spanning tree that minimizes the difference between its largest and smallest edge weight, or report -1 if disconnected. | Medium4 | Union-findSorting+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Indiana Jones and the Lost Soccer CupGiven precedence constraints between levers, decide whether the order is unique; print the unique order, or report no order or multiple orders. | Medium4 | Topological sortGraph+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Flash MobGiven n grid points, find the intersection minimizing the total Manhattan distance, breaking ties by smallest x then smallest y. | Medium4 | SortingMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| AlaskaGiven charging station positions along a 1422-mile highway and a 200-mile range, decide whether the round trip Dawson Creek to Delta Junction and back is possible. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Dragon of LoowaterMatch the smallest knight to each dragon head so that every head is cut by a tall enough knight, minimizing total height paid; report failure if impossible. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Y2K Accounting BugGiven monthly surplus s and deficit d, find the maximum yearly total over all 12 months given that every 5-month block is negative, or report Deficit. | Medium4 | Brute forceGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The TripGiven what each student spent, find the minimum total money that must change hands so every student ends up paying the same amount within one cent. | Medium4 | GreedyMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Australian VotingSimulate multi-round preferential voting: eliminate the lowest candidates each round and transfer their ballots until someone exceeds 50% or a tie remains. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Jungle RoadsGiven a connected weighted graph of villages and roads, find the minimum total maintenance cost of a set of roads that keeps every village connected. | Medium4 | Minimum spanning treeGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RopesGiven pitch lengths of a climb, compute the maximum number of climbers for 50, 60, and 70 meter ropes, or 0 if a rope is unsuitable. | Medium4 | SimulationGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Stable StringGiven a string of braces, find the minimum number of single-character flips that make all brackets correctly balanced. | Medium4 | StackGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Money MattersGiven each person's balance and a friendship graph, decide whether all debts can be settled by moving money only within connected components. | Medium4 | Union-findGraph+1 | No attempts yet | 1s | 128 MB | Judgeable |
| DiscountsFor each product, given buy-B-get-F-free offers and query amounts, find the maximum saving in dollars for each quantity. | Medium4 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Exotic FoodsGiven a sequence of food values, choose a subset with no two chosen positions adjacent so the total value is as large as possible. | Medium4 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| EcosystemGiven populations and per-member diets for species ordered by food chain position, simulate feeding in increasing species order and report survivors. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |