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,800 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Book ClubGiven each of N cows' answers to NQ questions, count how many cows match all P given question-answer pairs simultaneously. | Medium4 | Hash mapImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Bovine Fire DrillSimulate cows on a circular ring of N chairs, each moving clockwise by its own number, and report the cow that ends the drill. | Medium4 | SimulationImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Bessie's Weight ProblemGiven N haybale weights and a limit H, find the largest total weight at most H that can be formed by choosing each bale at most once. | Medium4 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Chivalrous CowFind the fewest knight-move jumps on an X by Y grid with obstacles to get from the start square to the hay bale. | Medium4 | BFSGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow PinballGiven a triangle of nail scores with R rows, find the maximum sum along a path from the top nail down to the last row, moving to one of the two adjacent nails below each step. | Medium4 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Music NotesGiven note durations that divide a timeline into consecutive intervals, answer queries asking which 1-based note covers a given time. Use prefix sums and binary search. | Medium4 | Prefix sumBinary search+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 |
| Find the Playing NoteGiven note durations that partition a timeline, answer queries asking which note covers a given beat by locating the prefix sum that brackets it. | Medium4 | Prefix sumBinary search+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 |
| Longest Contiguous SubsequenceGiven two integer sequences, find the length of the longest run of consecutive elements that appears in both. | Medium4 | Dynamic programmingArray+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 |
| Cruel Math TeacherCompute N raised to the power P exactly, then print the result with 70 digits per line and no leading zeros. | Medium4 | MathImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Look UpFor each cow, find the smallest index j > i with H_j > H_i, or print 0 if none exists. | Medium4 | StackArray+1 | 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 |
| 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 |
| 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 |
| Long Distance RacingGiven a terrain string and per-unit times, find the farthest segment index k whose round-trip time stays within M seconds. | Medium4 | ArrayPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Lake MakingApply each 3x3 stomp by flattening the block down to its maximum minus D, then sum water depth times 72*72 for squares below level E. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Hungry CowsGiven a sequence of N cow brands, find the length of the longest strictly increasing subsequence in the given order. | Medium4 | Dynamic programmingBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Word GamesGiven a rack of up to 10 letters with wildcards and a dictionary of up to 50000 words, print every dictionary word whose letters can be covered by the rack, in input order. | Medium4 | ImplementationBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Eating PuzzleGiven up to 21 bucket sizes and a calorie limit, choose a subset with the largest sum that does not exceed the limit. | Medium4 | Brute forceBit manipulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Bale TowerGiven up to 20 bales with distinct widths and breadths, find the longest chain where each bale is strictly smaller than the one below it. | Medium4 | Dynamic programmingSorting+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 |
| Word PuzzleGiven a letter grid and a list of words, find each word's starting cell and one of eight reading directions, choosing the earliest match by row, column, then direction. | Medium4 | ArrayBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Optimal Array Multiplication SequenceGiven the dimensions of a chain of matrices, find the minimum number of scalar multiplications needed to compute their product. | Medium4 | Dynamic programmingMatrix+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Transferable VotingSimulate an instant-runoff election with ranked ballots, discard invalid ones, eliminate lowest-vote candidates each round, and report the winner or the tied candidates. | Medium4 | SimulationImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| BorderGiven a counter-clockwise closed grid path, mark every square that lies outside the region and shares an edge with the path, then print the 32 by 32 bitmap. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| M*A*S*HSimulate a card-driven counting-out lottery on a line of P people until X survivors remain, then print their original positions in increasing order. | Medium4 | SimulationArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Message RoutingSimulate message routing through up to 10 MTAs whose tables use wildcards; report local delivery, routing loops, or unroutable messages. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| CowculationsFor each tablet, simulate three operations (add, shift right, shift left, or null) on a five-symbol cow number and check the padded result equals the eight-symbol line. | Medium4 | ImplementationSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Diplomatic LicenseGiven an odd number of points around a circle, find for each adjacent pair the midpoint of the segment joining them, printed with six decimals. | Medium4 | GeometryImplementation+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 |
| Stock ExchangeFor each issuer, for every bid output the agents on the opposite side whose price could match it, in input order. | Medium4 | ArrayImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Calendar of EventsGiven old and new schedules of N meetings, simulate prefix reversals that place each target day and list the request sizes. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Emag eht htiw Em PlehGiven White and Black piece lists, print the 8x8 chess board as ASCII art with alternating light and dark square fills. | Medium4 | ImplementationSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Idiot of the Year Contest!For each test case, count how many times a chosen digit occurs in the decimal representation of n! where n is at most 366. | Medium4 | MathImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Expression EvaluatorEvaluate a C-style expression of letter variables with binary + and -, plus pre and post ++ and --, then report the result and each used variable's final value. | Medium4 | StringSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Happy WormCount maximal horizontal and vertical runs of empty cells that are at least 2 long in a field with stones. | Medium4 | SortingImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bridge TransportGiven car weights and a bridge that holds at most 4 cars, find the largest prefix that can cross without any window of 4 consecutive cars exceeding the weight limit. | Medium4 | Sliding windowArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Keep on Truckin'Given fixed and added motel distances, count overnight stop sequences where each day covers between A and B km. | Medium4 | Dynamic programmingArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| OthelloSimulate up to 30 Othello moves on an 8x8 board starting from one of three configurations, then print the final black and white disc counts. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Floor PlanGiven a grid of walls and floor cells, count connected rooms, sort them by size, floor as many of the largest rooms as the wood supply allows, and report how many rooms got flooring plus the leftover wood. | Medium4 | DFSSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bridge CrossingSplit a line of people into consecutive groups of at most M, where each group costs its slowest member's time, and minimize the total cost. | Medium4 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Long DivisionDivide a large integer by another using the schoolbook long-division method of shifting and repeated subtraction. | Medium4 | MathImplementation+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 |
| SafebreakerGiven up to 10 guesses with correct-position and wrong-position digit counts, decide whether the secret 4-digit code is unique, impossible, or indeterminate. | Medium4 | Brute forceImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Where's Waldorf?Given a grid of letters and a list of words, find the first-letter position of each word along any of eight straight directions, or the bottom-right cell if absent. | Medium4 | ArrayString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Grandpa's Lottery GamesGiven daily lottery spending and winnings, report the overall profit sign, the single day with the largest loss, and the consecutive run with the largest total loss. | Medium4 | ArrayPrefix sum+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Paper StripsStrips are glued on a black strip in order, each hiding what lies below; print the visible color and length of each final segment, merging equal neighbors. | Medium4 | ImplementationArray+2 | No attempts yet | 6s | 1024 MB | Judgeable |
| Overshadowed TreesFor each tree, check whether any taller tree within K positions exceeds its height by at least M, and list all such trees. | Medium4 | Sliding windowArray+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| The RaceGiven the starting order of cars and a recorded list of adjacent overtakes, verify the sequence is valid and print the final order or the first impossible overtake. | Medium4 | SimulationArray+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| House NumbersGiven add and remove sub-orders over ranges of house numbers, find the set of numbers kept and count how many of each digit 0 to 9 appear across them. | Medium4 | ImplementationArray+2 | No attempts yet | 1s | 128 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 |
| Grandpa's Other EstateGiven up to 100 points and a square side length r, place the axis-aligned square to cover as many points as possible, counting border points as inside. | Medium4 | ArraySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Lock ManagerProcess lock requests in order, granting an S or X lock when it conflicts with no granted lock, denying it and blocking the transaction otherwise, and ignoring later requests from blocked transactions. | Medium4 | Hash mapSimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| On Storing ClothesSimulate a circular rail of hooks, depositing batches into the first fitting empty block and withdrawing them by ticket, printing freed hooks. | Medium4 | SimulationArray+1 | No attempts yet | 1s | 1024 MB | Judgeable |
| BowlingGiven the pins knocked down on each delivery of a valid ten-frame bowling game, compute the total score. | Medium4 | SimulationImplementation+2 | 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 |
| Dart ChallengeFor each dartboard, count how many distinct total scores k darts can produce, where each dart misses or scores s_i, 2s_i, or 3s_i (no triple on the top area). | Medium4 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TudokuFill in each 9x9 Sudoku board: whenever a row, column, or 3x3 block has exactly one empty cell, that cell is forced, and repeating this finishes every board. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BrainmanGiven a sequence, find the minimum number of adjacent swaps needed to sort it in non-decreasing order; this equals the number of inversions. | Medium4 | Divide and conquerSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Boundless BoxesGiven a grid and up to 1000 seed cells, find the largest Chebyshev distance from any cell to its nearest seed, plus one. | Medium4 | GeometryBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| To Eat or Be EatenCount pairs where an A creature is strictly larger than a B creature, given two lists of sizes. | Medium4 | SortingTwo pointers+2 | No attempts yet | 1s | 256 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 |
| Sultan's LandGiven P pillars on an N by N grid, count how many sets of four pillars form the corners of an axis-aligned rectangle. | Medium4 | ArrayHash map+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 |
| CannonsFor each query, report the minimum and maximum value in the given subarray of cannon strengths. | Medium4 | Segment treeArray | No attempts yet | 1s | 128 MB | Judgeable |
| Neighbouring TownsGiven a symmetric shortest-distance table for n towns, list every pair A,B such that no third town C satisfies dist(A,B) = dist(A,C) + dist(C,B). | Medium4 | ArrayBrute force | 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 |
| ImprovisationGiven a chord progression and a melody with pauses, remap each played note to the nearest note in the current chord's scale, advancing the chord every fourth position. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 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 |
| MatchesStarting from one match, fire spreads to each neighbor no taller than the burning match, and the task asks for the largest group that can burn. | Medium4 | Dynamic programmingArray | No attempts yet | 1s | 128 MB | Judgeable |
| Gathering MushroomsChoose the earliest day t of at least 1 that maximizes the total weight of mushrooms still edible, where each weight grows daily. | Medium4 | Prefix sumArray | No attempts yet | 1s | 128 MB | Judgeable |
| The Birthday PartyFind the smallest guest count m so that every candy pile leaves at least one leftover when divided equally among m guests. | Medium4 | Number theoryArray | No attempts yet | 1s | 128 MB | Judgeable |
| Recursive Pattern (Szlaczek)Given a starting sequence that is repeatedly extended by appending its own reversal, report the value at position M. | Medium4 | RecursionArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| StickersPick stickers from a 2 by n grid with no two sharing an edge to maximize the total score. | Medium4 | Dynamic programmingArray | No attempts yet | 1s | 256 MB | Judgeable |
| Diamond Mining ProfitsFind the contiguous period with the largest total gain across up to 2000 test cases, breaking ties by shorter length then earlier start. | Medium4 | Dynamic programmingArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Colorful ChainCount the contiguous segments that hold exactly the required number of links of each listed color and no other colors. | Medium4 | Sliding windowHash map+1 | No attempts yet | 3s | 512 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 |
| Ranked ChoiceSimulate ranked-choice runoff with batch elimination and print each round until a majority winner emerges or no winner remains. | Medium4 | SimulationArray | No attempts yet | 60s | 256 MB | Judgeable |
| Next permutationGiven a permutation of 1 to N, print the next permutation in lexicographic order, or -1 when the given one is the last. | Medium4 | ArrayTwo pointers | No attempts yet | 1s | 256 MB | Judgeable |
| Previous PermutationGiven a permutation of 1 to N, print the permutation that comes just before it in lexicographic order, or -1 when it is the first. | Medium4 | Array | No attempts yet | 1s | 256 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 |
| Climbing to the Information Science BuildingFind the crossing point k minimizing left-road distance from 1 to k plus crosswalk k plus right-road distance from k to n; output the smallest such k and the minimum distance. | Medium4 | Prefix sumArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| LiarsGiven a circular string of answers about whether the right neighbor is a liar, find the minimum number of liars consistent with all answers, or -1. | Medium4 | Brute forceImplementation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Important TestFor each variant, find the longest prefix solvable in t minutes given he may replace at most one task time with t0. Since order is fixed, choose the single task in that prefix whose copying saves the most time. | Medium4 | ArrayPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Q-indexGiven n citation counts, find the largest k such that at least k papers have k or more citations and the rest have at most k. | Medium4 | SortingArray | No attempts yet | 1s | 512 MB | Judgeable |
| Evenly Spaced TriplesGiven N distinct positions on a line, count how many triples of points have the middle point exactly halfway between the other two. | Medium4 | Hash mapArray | No attempts yet | 1s | 256 MB | Judgeable |
| Minimum overtakesGiven a starting order and a finishing order of up to 24 cars, print the minimum number of adjacent swaps that turn the start into the finish. | Medium4 | SortingArray+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Remove DuplicatesRead a space-separated list whose length is not given, keep each value only at its first occurrence, and print the surviving values in order. | Medium4 | Hash mapArray+2 | No attempts yet | 5s | 8 MB | Judgeable |
| Era NameGiven partial records mapping Western years to era names and regnal years, determine the era name and year for each query, or report Unknown when no record covers it. | Medium4 | ArraySorting+2 | No attempts yet | 8s | 512 MB | Judgeable |
| Pokemon TradingWith a fixed budget, buy on one day and sell on a later day to maximize profit; report the best result rounded to two decimals. | Medium4 | ArrayGreedy+1 | No attempts yet | 0.3s | 4 MB | Judgeable |
| Tandem BicyclePair each Dmojistan rider with a Pegland rider to minimize or maximize the sum of the larger speed in each pair. | Medium4 | GreedySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| TunnelGiven the entry order and exit order of N cars through a tunnel, count how many cars must have overtaken another car. | Medium4 | ArrayHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Amusement Park QueueTwo people walk a fixed grid path one step per minute, offset by K minutes; count the minutes their cells touch in any of eight directions. | Medium4 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Counting HaybalesGiven N distinct haybale positions and Q interval queries, count how many positions fall inside each inclusive range [A, B]. | Medium4 | SortingBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Box PackingGiven box sizes in order, find the longest subsequence where each box is strictly smaller than the next, counting boxes in the pile. | Medium4 | Dynamic programmingBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |