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 results2,730 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
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.Medium4SortingArray+2No attempts yet1s128 MBJudgeable
Hungry CowsGiven a sequence of N cow brands, find the length of the longest strictly increasing subsequence in the given order.Medium4Dynamic programmingBinary search+2No attempts yet1s128 MBJudgeable
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.Medium4Dynamic programmingSorting+2No attempts yet1s128 MBJudgeable
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.Medium4GreedySorting+2No attempts yet1s128 MBJudgeable
ArgusGiven queries that each fire every Period seconds starting at time Period, output the Q_num of the first K results, breaking ties by smaller Q_num.Medium4HeapSimulation+1No attempts yet1s128 MBJudgeable
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.Medium4SortingGreedy+2No attempts yet1s128 MBJudgeable
Scramble SortSort words case-insensitively and integers numerically within each comma-separated list while keeping each element's original type position.Medium4SortingString+2No attempts yet1s128 MBJudgeable
Inventory MaintenanceProcess new, delete, buy, sell, and report commands over a small inventory, printing sorted item tables with exact dollar amounts and profit since the last report.Medium4SimulationImplementation+2No attempts yet1s128 MBJudgeable
Making the GradeCompute each student's average after dropping the lowest test if more than two tests exist, then derive class mean and standard deviation, apply bonus and attendance letter-grade rules, and print the class GPA.Medium4ImplementationMath+2No attempts yet1s128 MBJudgeable
Etaoin ShrdluConcatenate each sample's lines, count overlapping adjacent character pairs, then print the five most frequent digrams with their counts and rounded relative frequencies.Medium4StringHash map+2No attempts yet1s128 MBJudgeable
Stock ExchangeFor each issuer, for every bid output the agents on the opposite side whose price could match it, in input order.Medium4ArrayImplementation+2No attempts yet1s128 MBJudgeable
Calendar of EventsGiven old and new schedules of N meetings, simulate prefix reversals that place each target day and list the request sizes.Medium4SimulationImplementation+2No attempts yet1s128 MBJudgeable
The Happy WormCount maximal horizontal and vertical runs of empty cells that are at least 2 long in a field with stones.Medium4SortingImplementation+2No attempts yet1s128 MBJudgeable
Keep on Truckin'Given fixed and added motel distances, count overnight stop sequences where each day covers between A and B km.Medium4Dynamic programmingArray+1No attempts yet1s128 MBJudgeable
BoxesFor each item, find the standard box with the smallest volume that can contain it after 90-degree rotations, or report that none fits.Medium4SortingImplementationNo attempts yet1s128 MBJudgeable
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.Medium4DFSSorting+2No attempts yet1s128 MBJudgeable
Common WordsFor each data set, count word frequencies, find the k-th most common words, and print them alphabetically after a title line.Medium4Hash mapSorting+2No attempts yet1s128 MBJudgeable
Maximum DistanceGiven two non-increasing arrays, find the largest j - i such that j >= i and Y[j] >= X[i].Medium4ArrayTwo pointers+2No attempts yet1s128 MBJudgeable
Bad CowtractorsGiven an undirected weighted graph, find a spanning tree of maximum total edge cost, or report -1 if no spanning tree exists.Medium4Minimum spanning treeGreedy+2No attempts yet1s128 MBJudgeable
Similar TrianglesGiven two triangles by integer vertex coordinates, decide whether they are similar and if so print the squared similarity coefficient as a reduced fraction p/q, else print -1.Medium4GeometryMath+2No attempts yet1s1024 MBJudgeable
Geocaching CoordinatesGiven a coordinate formula with placeholder letters and each letter's allowed digit values, print every distinct resulting coordinate in lexicographic order.Medium4Brute forceImplementation+1No attempts yet1s1024 MBJudgeable
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.Medium4ImplementationArray+2No attempts yet6s1024 MBJudgeable
Cosmic AssemblyFind integer coordinates (x, y, z) minimizing the sum of Manhattan distances to N given points, breaking ties lexicographically.Medium4MathSorting+1No attempts yet1s1024 MBJudgeable
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.Medium4GraphGreedy+2No attempts yet1s1024 MBJudgeable
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.Medium4GreedySorting+2No attempts yet1s128 MBJudgeable
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.Medium4ArraySorting+2No attempts yet1s128 MBJudgeable
Ancient CipherGiven two equal-length strings of capital letters, decide whether the first can be obtained from the second by a substitution cipher followed by a permutation.Medium4StringSorting+2No attempts yet2s128 MBJudgeable
Disk TreeGiven full directory paths, rebuild the tree and print every directory name on its own line, indented by depth, with siblings in ASCII order.Medium4TrieSorting+1No attempts yet1s128 MBJudgeable
RatingMerge two contest result tables into one ordering by the rules: teams present in both contests are ranked by the sum of their two places, and single-contest teams are placed where the rules allow.Medium4ImplementationSortingNo attempts yet1s128 MBJudgeable
Acid TextParse a simplified CSS style sheet, resolve each graphic's absolute or relative position, then composite the graphics by layer order into one canvas with a black background.Medium4ImplementationSimulation+2No attempts yet1s128 MBJudgeable
BrainmanGiven a sequence, find the minimum number of adjacent swaps needed to sort it in non-decreasing order; this equals the number of inversions.Medium4Divide and conquerSorting+1No attempts yet1s128 MBJudgeable
Ranking ListBuild a contest scoreboard: rank teams by solved problems then total time, with ties sharing a rank and listed alphabetically.Medium4SortingImplementation+1No attempts yet1s128 MBJudgeable
Gathering PointsGiven M points on an N by N grid, find a cell minimizing the sum of Manhattan distances from all points to it.Medium4MathSorting+1No attempts yet1s256 MBJudgeable
Dreadful DeadlinesGiven n jobs with durations and deadlines, find the latest start time from which all jobs can still be finished by their deadlines.Medium4GreedySortingNo attempts yet1s128 MBJudgeable
People in the CompanyGiven access-card records of enter and leave events, list the names of employees who are currently inside the office, sorted in reverse alphabetical order.Medium4Hash mapSorting+1No attempts yet1s256 MBJudgeable
To Eat or Be EatenCount pairs where an A creature is strictly larger than a B creature, given two lists of sizes.Medium4SortingTwo pointers+2No attempts yet1s256 MBJudgeable
HotelFor each team, pick the cheapest hotel in its bed-size category that can hold the team, breaking ties by larger bed size and then input order.Medium4ImplementationBrute force+2No attempts yet1s128 MBJudgeable
Minimum SwapsFor each string of distinct lowercase letters, find the minimum number of arbitrary swaps needed to sort it into alphabetical order.Medium4SortingGreedy+2No attempts yet1s128 MBJudgeable
Sales ReportGiven N sale records of item, salespoint, and quantity, print a table of totals with items as columns and salespoints as rows.Medium4SortingHash map+2No attempts yet4s128 MBJudgeable
CanoesGiven a canoe weight limit and each participant's weight, find the minimum number of two-person canoes needed to carry everyone.Medium4GreedyTwo pointers+2No attempts yet1s128 MBJudgeable
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.Medium4SortingGreedyNo attempts yet1s128 MBJudgeable
Grid Shading PuzzleGiven per-row and per-column shaded counts for an n by n board, decide whether a valid 0/1 board exists.Medium4GreedySortingNo attempts yet1s128 MBJudgeable
CoinsCount the ways to place coins of sizes 1 to n into slots with capacities a_i so every coin fits, modulo 1000000007.Medium4SortingCombinatorics+1No attempts yet1s512 MBJudgeable
SoldiersCount the monotonic lineups of n distinguishable soldiers by height and output the last four digits of the count.Medium4CombinatoricsMath+1No attempts yet1s512 MBJudgeable
Dollars and EurosSelect n of 2n-1 wallets with the fixed dollar-sorted rule so dollars and euros each reach half the totals.Medium4SortingSimulationNo attempts yet1s128 MBJudgeable
Indiana Jones Among the ZombiesEvery turn each zombie steps toward chamber 1 along a shortest path, and you find the first turn with more than K arrivals or confirm Indiana survives.Medium4BFSShortest path+1No attempts yet6s128 MBJudgeable
Exam PreparationSchedule preparation days before each exam day and find how many days before the earliest exam study must start.Medium4GreedySortingNo attempts yet1s128 MBJudgeable
Guess the WordGiven each uppercase word, output the next distinct arrangement of its letters in dictionary order, or the word itself when it is already last.Medium4StringSortingNo attempts yet1s128 MBJudgeable
Lucky LightCount the lighted regions on the x-axis that lie outside the shadows a point light casts from the given segments.Medium4GeometryIntervals+1No attempts yet1s128 MBJudgeable
Starship Hakodate-maruGiven a limit up to 151200, find the largest amount that splits into a cube plus a tetrahedral number.Medium4Brute forceSorting+2No attempts yet1s128 MBJudgeable
Hotel ReservationsFind the fewest rooms that fit all reservations when a room freed at checkout needs C more minutes of cleaning.Medium4IntervalsSorting+2No attempts yet2s128 MBJudgeable
A Voting ProtocolSimulate ranked-ballot rounds where each voter backs the top unpicked candidate and the top vote getters fill k seats with alphabetical tie breaks.Medium4SimulationSortingNo attempts yet1s128 MBJudgeable
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.Medium4GreedySorting+1No attempts yet2s64 MBJudgeable
Rental car management troubleProcess each spy's rental events in order and print spies by name with the total bill or INCONSISTENT for a broken record.Medium4SimulationImplementation+1No attempts yet2s128 MBJudgeable
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.Medium4GreedySorting+1No attempts yet1s128 MBJudgeable
Handing Out BooksAssign each applicant at most one distinct book numbered within their requested interval to maximize the number of satisfied applicants.Medium4GreedyIntervals+1No attempts yet2s256 MBJudgeable
Area Between Outer Hull and Inner HullCompute the convex hull of up to 1000 points twice, removing corner vertices after the first pass, and print the difference of the two polygon areas.Medium4GeometrySortingNo attempts yet5s128 MBJudgeable
uHuntProcess judge submissions in order and after each one report the leader's time and the submitter's rank by personal best, ignoring non-improving resubmissions.Medium4SortingHash map+1No attempts yet1s128 MBJudgeable
WalkingWalkers start at distinct times with fixed speeds, and a later starter who arrives earlier befriends the other; find the largest group where every pair meets.Medium4Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
Bessie Slows DownBessie runs 1000 metres with speed 1/(k+1) after k slowdowns triggered by time or distance events, and the total time is rounded to the nearest second.Medium4SimulationSorting+1No attempts yet1s128 MBJudgeable
Word ExtractionClean each input line by lowercasing it, joining or splitting words at punctuation by neighbor rules, then print the sorted unique words per line.Medium4StringSorting+1No attempts yet1s128 MBJudgeable
Auto-CompleteThe app prints the original index of the K-th dictionary word with each query prefix in alphabetical order, or -1.Medium4TrieSortingNo attempts yet1s128 MBJudgeable
Watering the FieldsConnect all fields with pipes costing at least C while minimizing total squared distance, or report -1 when impossible.Medium4Minimum spanning treeUnion-find+1No attempts yet1s128 MBJudgeable
Lazy Polar BearChoose a point on the line so the buckets within distance K of it hold the most ice in total.Medium4Sliding windowSorting+1No attempts yet1s128 MBJudgeable
Counting InversionsCount the pairs in a permutation of 1 to n where a larger number stands before a smaller one.Medium4Divide and conquerSortingNo attempts yet1s256 MBJudgeable
RummikubFrom 14 tiles, find the highest scoring group or run, break ties by sorted tile order, and print it with its score.Medium4Brute forceSorting+1No attempts yet1s256 MBJudgeable
UnitsGiven N-1 pairwise conversion relations, sort the units from largest to smallest and print the chain with the largest unit set to 1.Medium4GraphSorting+1No attempts yet3s256 MBJudgeable
Pangaea 1After each added road, compute the cheapest total length connecting all cities and XOR the m totals per test case.Medium4Minimum spanning treeUnion-find+1No attempts yet20s256 MBJudgeable
Classroom assignmentGiven N class time intervals, find the smallest number of rooms so overlapping classes never share a room.Medium4GreedySorting+2No attempts yet1s256 MBJudgeable
Troop MovementFind the route between two cities whose narrowest road is as wide as possible and report that width.Medium4Minimum spanning treeUnion-find+1No attempts yet2s256 MBJudgeable
City PlanningRebuild the smallest one-way road network matching a given reachability matrix, with cycles inside mutually reachable groups and cover edges between groups.Medium4GraphMatrix+1No attempts yet2s256 MBJudgeable
Kindergarten ExcursionCount the minimum adjacent swaps needed to reorder a string of 0s, 1s, and 2s into sorted order.Medium4SortingPrefix sumNo attempts yet1s256 MBJudgeable
Dr Who's BanquetBuild a chat graph whose vertex degrees equal the given wishes with the stated greedy construction, or print fail.Medium4GraphGreedy+1No attempts yet1s256 MBJudgeable
CompetitionFind the fewest seat changes that let Alice and Bob solve every solvable problem in contest order.Medium4GreedySortingNo attempts yet1s256 MBJudgeable
TriangleDecide whether two given integer-sided triangles are congruent right triangles that can form a rectangle split along its diagonal.Medium4GeometryMath+1No attempts yet2s256 MBJudgeable
ExcellencePair all students into teams of two so the smallest team rating sum is as large as possible.Medium4GreedySorting+1No attempts yet2s256 MBJudgeable
Points on a SegmentCount how many of N distinct points fall inside each of M closed intervals on a line.Medium4Binary searchSortingNo attempts yet1s256 MBJudgeable
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.Medium4GreedySortingNo attempts yet2s512 MBJudgeable
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.Medium4Binary searchGreedy+1No attempts yet2s512 MBJudgeable
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.Medium4GreedySortingNo attempts yet1s128 MBJudgeable
Sums of Sums (Small)You sort every contiguous subarray sum of an array and answer range sums over the sorted list.Medium4SortingPrefix sumNo attempts yet5s512 MBJudgeable
Packing Files onto DiscsPack all files onto the fewest discs of capacity X with at most two files per disc.Medium4GreedyTwo pointers+1No attempts yet5s512 MBJudgeable
Data PackingPack files onto discs holding at most two files of total size X using the fewest discs.Medium4GreedyTwo pointers+1No attempts yet5s512 MBJudgeable
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.Medium4GreedySortingNo attempts yet5s512 MBJudgeable
Minimum Keypresses for Text EntryAssign each letter to a key and a position so that total presses, the frequency times the position, is minimized.Medium4GreedySorting+2No attempts yet5s512 MBJudgeable
Minimum Scalar Product (Small)Permute two vectors to minimize their dot product and print the minimum.Medium4SortingGreedy+1No attempts yet5s512 MBJudgeable
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.Medium4SortingGreedy+2No attempts yet5s512 MBJudgeable
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.Medium4GreedySorting+2No attempts yet5s512 MBJudgeable
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.Medium4GreedySorting+1No attempts yet5s512 MBJudgeable
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.Medium4ImplementationGreedy+1No attempts yet2s512 MBJudgeable
Correcting CheeseburgersGiven a permutation of 1 to n, find the minimum number of four-part shuffles (c,a,d,b) needed to sort it into 1,2,...,n.Medium4BFSBrute force+2No attempts yet2s512 MBJudgeable
HoneyGiven N hives with honey amounts, a pot of capacity M, and at most K trips, maximize the total honey collected.Medium4GreedySorting+1No attempts yet1s64 MBJudgeable
Prefix ArraySort all prefixes of a string lexicographically and print the end index of each prefix in that order.Medium4SortingString+1No attempts yet2s512 MBJudgeable
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.Medium4SortingArrayNo attempts yet1s512 MBJudgeable
RearrangeChoose an ordering of the array, subtract elements from n in that order until n drops to 0 or below, and report the smallest achievable result.Medium4GreedySortingNo attempts yet1s512 MBJudgeable
Justice Rains from Above!Given each robot's coordinates and missile speed, output the robot indices sorted by hit time (distance divided by speed), breaking ties by smaller index.Medium4SortingMath+1No attempts yet1s128 MBJudgeable
Sticky SituationGiven N stick lengths, decide whether some three of them can form a triangle with positive area.Medium4SortingGreedyNo attempts yet2s512 MBJudgeable
Stick GameGiven counts of sticks of distinct lengths, find the maximum number of rectangles (squares allowed) that can be built using each stick at most once.Medium4GreedySortingNo attempts yet2s512 MBJudgeable
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.Medium4SortingArray+1No attempts yet2s512 MBJudgeable
Mismatched SocksGiven counts of socks per color, find the maximum number of pairs where each pair uses two different colors and every sock is in at most one pair.Medium4GreedyMath+1No attempts yet2s512 MBJudgeable