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 |
|---|---|---|---|---|---|---|
| Emergency ResponseGiven a directed weighted graph, answer multiple queries: the shortest travel time from any of several start nodes to one crime intersection. | Medium4 | GraphShortest path+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Open IntervalsGiven up to 50 open intervals per test case, pick the largest subset where no two intervals overlap, counting touching endpoints as compatible. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Next PermutationGiven an integer A, find the smallest permutation of its digits that is strictly greater than A, or print USELESS if none exists. | Medium4 | ArrayString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Stacking BooksGiven a stack of book sizes, find the fewest moves that pull one book to the top (only when the part above it is non-decreasing) to sort the stack. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Best PizzaChoose any subset of toppings, each costing B, to maximize total calories divided by total price, and print the floor of that ratio. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Tornado!Given a circular fence of N posts marked standing or broken, choose the fewest broken posts to fill so no wire span between standing posts exceeds 4 meters. | Medium4 | GreedyArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow CrossingsCount cows whose straight crossing paths intersect no other cow, where two paths cross exactly when the start and end left-to-right orders differ. | Medium4 | SortingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GiftGiven each friend's item price and shipping cost and one coupon that halves a single item price, find the most gifts buyable within budget B. | Medium4 | SortingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Heat WaveGiven an undirected weighted graph, find the minimum total cost of a route from a source town to a destination town. | Medium4 | GraphShortest path+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Selfish GrazingGiven N intervals, find the maximum number of intervals that can be chosen so that no two of them overlap. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Chocolate BuyingGiven N chocolate types with a cost per piece and a number of cows wanting each, spend a budget B to satisfy as many cows as possible. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Maximize the AccelerationGiven N parts that each add force and mass, choose the subset maximizing total force divided by total mass, breaking ties by smaller mass. | Medium4 | Brute forceBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Widest MountainGiven a sequence of heights, find the longest contiguous run that is non-decreasing then non-increasing; valleys are shared by both neighboring mountains. | Medium4 | ArrayImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Mountain WatchingGiven a sequence of heights, find the longest consecutive block that rises (non-strictly) then falls (non-strictly), allowing a block that only rises or only falls. | Medium4 | ArrayTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Time ManagementGiven each chore's duration and deadline, find the latest start time that lets John finish all chores before their deadlines, or print -1. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ScrabbleGiven a tray of T letters (some blanks that score 0) and an alphabetized dictionary, pick the highest-scoring dictionary word formable from the tray, breaking ties alphabetically. | Medium4 | StringGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| O Those FadsCows join a fad when its attractiveness L reaches their resistance; each joiner raises L by K. Count the final number of participants. | Medium4 | SortingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Speed ReadingFor each cow, simulate reading in bursts of at most T minutes with R-minute rests between, and report the total minutes rounded up to finish N pages. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bookshelf 2Given up to 20 cow heights and a target bookshelf height B, find the minimum amount by which some subset's total height exceeds or equals B. | Medium4 | Brute forceBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Election TimeEach cow has first round votes A and second round votes B; the top K by A advance, then the one with the largest B among them wins. Output the winner's index. | Medium4 | SortingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| iCowRepeatedly pick the highest-rated song, reset its rating to 0, and spread its points over the others until T songs are played. | Medium4 | SimulationImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Dining CowsGiven a sequence of 1s and 2s, find the minimum number of values to change so the sequence becomes nondecreasing. | Medium4 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Clear and Present DangerGiven a danger matrix and a required sequence of islands, find the minimum total danger of a walk that visits those islands in order, allowing detours through others. | Medium4 | GraphShortest path+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Buy One Get One FreeBuy all N high quality bales, then pair as many of the M low quality bales as possible so each free bale is strictly smaller than its distinct high quality partner. Output N plus the maximum number of pairs. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bronze Cow PartyGiven a connected undirected weighted graph, find twice the largest shortest-path distance from a fixed farm X, which is the longest round trip any cow makes. | Medium4 | Shortest pathGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Team ArrangementPick the lowest-numbered players for each role to match a formation, then name the selected player with the most years served as captain. | Medium4 | SortingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Suspicious StocksGiven daily stock prices and starting cash, buy as many whole shares as possible on one day, then sell all on a later day, and report the maximum profit. | Medium4 | ArrayBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BudgetGiven row sums, column sums, and bound constraints on individual cells or whole rows/columns, decide whether a matrix of non-negative integers exists. | Medium4 | GreedyMath+1 | No attempts yet | 1s | 256 MB | Judgeable |
| It’s tough being a teen!Given a fixed list of seven tasks with precedence rules plus up to ten extra constraints, output a valid order using the smallest available task first, or report that no order exists. | Medium4 | GraphTopological sort+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GolfGiven a target distance and up to 32 distinct club distances, find how many strokes give an exact sum, using unlimited repeats of each club. | Medium4 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Maximum DistanceGiven two non-increasing arrays, find the largest j - i such that j >= i and Y[j] >= X[i]. | Medium4 | ArrayTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bad CowtractorsGiven an undirected weighted graph, find a spanning tree of maximum total edge cost, or report -1 if no spanning tree exists. | Medium4 | Minimum spanning treeGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Milk and HoneyAssign each field to cows or bees to maximize total happiness, where each field's output value declines linearly with each added unit. | Medium4 | GreedyMath+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| Cosmic AssemblyFind integer coordinates (x, y, z) minimizing the sum of Manhattan distances to N given points, breaking ties lexicographically. | Medium4 | MathSorting+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| BossesGiven a graph of projects where the lower-numbered endpoint is the boss, find the max number of edges so every vertex has at most one boss, minimizing cancellations. | Medium4 | GraphGreedy+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| InternetGiven measurements with connection states, where the first and last show a connection, find the longest possible time the connection could have been down. | Medium4 | GreedyImplementation+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| Rotten RopesGiven the tear-off weights of n ropes, find the maximum object weight that a chosen subset can carry so that no rope in the subset breaks. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ParliamentSplit N delegates into groups of distinct sizes so that the product of the sizes is maximized, and print the sizes in ascending order. | Medium4 | MathGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| BukazoidsGiven cell counts and a fixed number of single and double jumps, maximize collected bukazoids and output the lexicographically smallest optimal visit sequence. | Medium4 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Holiday GiftsAssign one of two priced gifts to each node of a rooted tree so no two adjacent employees share a gift, minimizing total cost. | Medium4 | TreeDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Gathering PointsGiven M points on an N by N grid, find a cell minimizing the sum of Manhattan distances from all points to it. | Medium4 | MathSorting+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Dreadful DeadlinesGiven n jobs with durations and deadlines, find the latest start time from which all jobs can still be finished by their deadlines. | Medium4 | GreedySorting | No attempts yet | 1s | 128 MB | Judgeable |
| Baking CakesGiven up to 40 cake baking times and 3 ovens, find the minimum time to bake all cakes. | Medium4 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Trigonometric OptimizationChoose positive integers x, y, z summing to S to optimize sin/cos(x)+sin/cos(y)+sin/cos(z), rounded to 10 decimals. | Medium4 | MathBrute force+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Minimum SwapsFor each string of distinct lowercase letters, find the minimum number of arbitrary swaps needed to sort it into alphabetical order. | Medium4 | SortingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Longest Ordered SubsequenceGiven a sequence of N integers, find the length of the longest non-decreasing subsequence. | Medium4 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Holiday CostingFor each stay length at a hotel, choose one stay/pay deal, repeated as allowed, to minimize the nights you pay for. | Medium4 | Brute forceImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| CanoesGiven a canoe weight limit and each participant's weight, find the minimum number of two-person canoes needed to carry everyone. | Medium4 | GreedyTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TrianglesGiven a list of segment lengths, find the largest perimeter of a non-degenerate triangle formed by three of them, or print NIE if none exists. | Medium4 | SortingGreedy | No attempts yet | 1s | 128 MB | Judgeable |
| Grid Shading PuzzleGiven per-row and per-column shaded counts for an n by n board, decide whether a valid 0/1 board exists. | Medium4 | GreedySorting | No attempts yet | 1s | 128 MB | Judgeable |
| SingingThe task is to place the fewest books so every student in a row has one or sits next to one. | Medium4 | Greedy | No attempts yet | 1s | 512 MB | Judgeable |
| CoinsCount the ways to place coins of sizes 1 to n into slots with capacities a_i so every coin fits, modulo 1000000007. | Medium4 | SortingCombinatorics+1 | No attempts yet | 1s | 512 MB | Judgeable |
| TrainCount the fewest round trips a train needs to drop its wagons from the back at their assigned cities in order. | Medium4 | GreedyHash map | No attempts yet | 1s | 512 MB | Judgeable |
| DrawersPush as few drawers in as possible so the pull-out lengths strictly increase from the top drawer down. | Medium4 | GreedyArray | No attempts yet | 1s | 128 MB | Judgeable |
| Exam PreparationSchedule preparation days before each exam day and find how many days before the earliest exam study must start. | Medium4 | GreedySorting | No attempts yet | 1s | 128 MB | Judgeable |
| Match MakerPair N men with N women from full preference lists to output the man-optimal stable matching with no blocking pair. | Medium4 | SimulationGreedy | No attempts yet | 1s | 128 MB | Judgeable |
| Hotel ReservationsFind the fewest rooms that fit all reservations when a room freed at checkout needs C more minutes of cleaning. | Medium4 | IntervalsSorting+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Network PlanningPick M cities for new stations to maximize total supply, where each station covers 70 percent of its own demand plus 10 percent of each neighbor's. | Medium4 | GreedySorting+1 | No attempts yet | 2s | 64 MB | Judgeable |
| A site just for programming contestsBuy each plot in decreasing price order, one per year, and report the total cost or Too expensive when it exceeds the budget. | Medium4 | GreedySorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Handing Out BooksAssign each applicant at most one distinct book numbered within their requested interval to maximize the number of satisfied applicants. | Medium4 | GreedyIntervals+1 | No attempts yet | 2s | 256 MB | Judgeable |
| NASSA's RobotYou get a walk of UDLR steps with ? wildcards that can stop after any prefix, and you report the smallest and largest reachable X and Y. | Medium4 | GreedySimulation | No attempts yet | 1s | 128 MB | Judgeable |
| Lottery 2Change as few entries as possible in a length-n sequence over 1 to k so no two adjacent entries are equal. | Medium4 | GreedyArray | No attempts yet | 1s | 128 MB | Judgeable |
| Rearranging a Bit StringFind the fewest adjacent swaps turning the start bits into one of the strings matching the run code. | Medium4 | GreedyBrute force | No attempts yet | 1s | 256 MB | Judgeable |
| Train TravelCount how many times each rail is crossed and pay the cheaper of single tickets or a discount card plus cheap fares for every rail. | Medium4 | Prefix sumGreedy | No attempts yet | 1s | 256 MB | Judgeable |
| AirportEach arriving plane takes the largest free gate up to its limit gi, and the count stops at the first plane with no free gate. | Medium4 | Union-findGreedy | No attempts yet | 1s | 256 MB | Judgeable |
| NetworkAdd the fewest edges to a tree so it stays connected after any single edge breaks, pairing leaves in the prescribed DFS order. | Medium4 | TreeDFS+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Classroom assignmentGiven N class time intervals, find the smallest number of rooms so overlapping classes never share a room. | Medium4 | GreedySorting+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Jump JumpStarting from the first cell, find the fewest rightward jumps bounded by each cell value to reach the last cell, or -1 when unreachable. | Medium4 | Dynamic programmingGreedy | No attempts yet | 1s | 256 MB | Judgeable |
| Dr Who's BanquetBuild a chat graph whose vertex degrees equal the given wishes with the stated greedy construction, or print fail. | Medium4 | GraphGreedy+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Icelandic MotorclubsFind the smallest-numbered station from which a rider who takes all gas at every stop can complete one clockwise lap. | Medium4 | GreedyPrefix sum | No attempts yet | 3s | 256 MB | Judgeable |
| Popping BalloonsPop every balloon from left to right with the fewest rightward arrows that drop one unit after each hit. | Medium4 | GreedyHash map | No attempts yet | 2s | 256 MB | Judgeable |
| CompetitionFind the fewest seat changes that let Alice and Bob solve every solvable problem in contest order. | Medium4 | GreedySorting | No attempts yet | 1s | 256 MB | Judgeable |
| ExcellencePair all students into teams of two so the smallest team rating sum is as large as possible. | Medium4 | GreedySorting+1 | No attempts yet | 2s | 256 MB | Judgeable |
| GeneratorsSimulate each bounded generator to find its largest reachable value, then lower one value by the smallest loss that breaks divisibility by k. | Medium4 | GreedySimulation | No attempts yet | 1s | 256 MB | Judgeable |
| Birthday Numbers IFind the numerically smallest number made only of digits 3, 5 and 8 whose digits add up to N, or -1 when none exists. | Medium4 | GreedyMath | No attempts yet | 1s | 256 MB | Judgeable |
| High Card WinsAssign each of Bessie's N cards to a round against Elsie's fixed play order to win the most rounds with the higher card. | Medium4 | GreedySorting | No attempts yet | 2s | 512 MB | Judgeable |
| Angry Cows (Silver)Find the smallest integer blast radius R so K intervals of length 2R cover all N hay bale positions on a line. | Medium4 | Binary searchGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Mileage Course RegistrationGiven each course rival bids and capacity, bid 1 to 36 points per chosen course, winning ties, to take the most courses with m points. | Medium4 | GreedySorting | No attempts yet | 1s | 128 MB | Judgeable |
| TelephonesAdd the fewest phones to empty desks so a ring hops from the first desk to the last with each hop spanning at most D. | Medium4 | GreedyArray | No attempts yet | 1s | 64 MB | Judgeable |
| Mushroom Monster (Large)From plate counts taken every 10 seconds, compute the minimum mushrooms eaten under free eating and under the smallest consistent constant rate. | Medium4 | GreedySimulation+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Packing Files onto DiscsPack all files onto the fewest discs of capacity X with at most two files per disc. | Medium4 | GreedyTwo pointers+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Data PackingPack files onto discs holding at most two files of total size X using the fewest discs. | Medium4 | GreedyTwo pointers+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Cookie FarmsDecide how many cookie farms to buy before waiting so the time to hold X cookies is as short as possible. | Medium4 | GreedyMath | No attempts yet | 5s | 512 MB | Judgeable |
| Lawnmower (Small)Decide if row and column cuts of a mower that only lowers grass can produce the given target heights from a uniform lawn. | Medium4 | GreedyMatrix | No attempts yet | 5s | 512 MB | Judgeable |
| Lawnmower (Large)Decide whether a target grid of grass heights is reachable from height 100 by cutting whole rows or columns down to chosen levels. | Medium4 | GreedyMatrix | No attempts yet | 5s | 512 MB | Judgeable |
| Dancing With the Googlers (Small)Given each dancer's total of three judge scores and a budget of surprising triplets, maximize the count of dancers whose best score reaches p. | Medium4 | GreedyMath | No attempts yet | 5s | 512 MB | Judgeable |
| Dancing With the Googlers (Large)Given each dancer's total of three close scores and a limit on surprising splits, count the most dancers that reach a best score of p. | Medium4 | Greedy | No attempts yet | 5s | 512 MB | Judgeable |
| Closing the Loop (Small)Pick equal numbers of red and blue segments with the largest lengths and subtract one centimeter per knot to get the longest alternating loop. | Medium4 | GreedySorting | No attempts yet | 5s | 512 MB | Judgeable |
| Painting a fence (small)From up to 10 offers, choose the fewest that cover sections 1 to 10000 using at most 3 distinct colors. | Medium4 | Brute forceIntervals+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Minimum Keypresses for Text EntryAssign each letter to a key and a position so that total presses, the frequency times the position, is minimized. | Medium4 | GreedySorting+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Minimum Scalar Product (Small)Permute two vectors to minimize their dot product and print the minimum. | Medium4 | SortingGreedy+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Minimum Scalar Product (Large)Reorder the coordinates of two equal-length integer vectors so their scalar product is as small as possible, and report that minimum for each test case. | Medium4 | SortingGreedy+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Milkshakes (Large)Assign each of N flavors malted or unmalted so every customer gets a liked type, using the fewest malted batches, or report IMPOSSIBLE. | Medium4 | GreedyImplementation | No attempts yet | 5s | 512 MB | Judgeable |
| Train Timetable (Small)Given a day's timetable and a turnaround time, find the minimum number of trains that must start the day parked at each of the two stations. | Medium4 | GreedySorting+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Train Timetable (Large)Given each train's departure and arrival times plus a turnaround time, find the minimum trainsets needed at stations A and B to run the timetable. | Medium4 | GreedySorting+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Bit Friendship IndexGiven two equal-length binary strings, find the minimum number of digit changes and character swaps to make them identical. | Medium4 | StringGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Road Network of a Perfect Binary TreeFind the minimum number of cars whose vertex-disjoint paths cover every vertex of a perfect binary tree of height H exactly once. | Medium4 | TreeDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| A Restaurant for BearsEach arriving bear takes the smallest empty chair at or above its wanted number that is at least d away from every seated bear. | Medium4 | ImplementationGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Tree and paths of length twoDecide whether some tree on N nodes has exactly S simple paths of length 2. | Medium4 | TreeCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| ABCFind the lexicographically smallest length-N string over A, B, C that has exactly K pairs i < j with S[i] < S[j]. | Medium4 | GreedyCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |