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,732 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
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.Medium4ArraySorting+2No attempts yet8s512 MBJudgeable
Delete and Append SortEach operation moves one element to the end. Find the minimum number of such moves needed to sort the array.Medium4GreedySortingNo attempts yet2s512 MBJudgeable
Tandem BicyclePair each Dmojistan rider with a Pegland rider to minimize or maximize the sum of the larger speed in each pair.Medium4GreedySorting+2No attempts yet2s512 MBJudgeable
Wheat HarvestFind each connected block of 1s, order blocks by area, and label every cell with its block's rank.Medium4GraphDFS+1No attempts yet1s128 MBJudgeable
Counting HaybalesGiven N distinct haybale positions and Q interval queries, count how many positions fall inside each inclusive range [A, B].Medium4SortingBinary search+2No attempts yet2s512 MBJudgeable
Merging SlimesMerge N slimes two at a time, scoring the product of merged sizes, and maximize the total score.Medium4GreedySortingNo attempts yet2s512 MBJudgeable
Point CardGiven M cards with A wins out of 2N cells, pay 1 yen per flipped stamp to make at least M-1 cards hold N or more wins; minimize total cost.Medium4GreedySorting+1No attempts yet2s512 MBJudgeable
Ingenious Lottery TicketsCount how often each number 1 to 49 appears across n lottery entries, then pick the six most frequent, breaking ties by favoring 7 and then smaller numbers.Medium4SortingArrayNo attempts yet2s512 MBJudgeable
Prime GameSimulate a two-player game where each spoken prime is recorded per player, duplicates cost 1000 points, and a non-prime gives the opponent their third largest prime or 1000.Medium4SimulationImplementation+2No attempts yet2s256 MBJudgeable
The TA is a sadist!!Given a permutation of 1 to N, find the minimum number of elements to remove so the remaining values increase from front to back.Medium4Dynamic programmingBinary search+2No attempts yet2s256 MBJudgeable
STOP USING MONEYSort N games by satisfaction-to-price ratio, then by lower price, then by game number, and print the first K game numbers.Medium4SortingMath+2No attempts yet1s512 MBJudgeable
The Seven WarlordsGiven up to ten million student grades, output the seven lowest grades in increasing order, one per line. Ties on the cut line still yield exactly seven grades.Medium4SortingHeap+2No attempts yet10s256 MBJudgeable
MultiMaxGiven n cards with values in [-1000, 1000], pick two or three so their product is maximized.Medium4SortingGreedy+1No attempts yet1s512 MBJudgeable
Party GamesFor each test case, find the shortest string that splits the sorted guest names into two equal halves, choosing the alphabetically first if several have that length.Medium4StringSorting+1No attempts yet2s512 MBJudgeable
Steed 2: Cruise Control (Small)Given horses ahead on a one-way road that slow to match slower horses they catch, find the fastest constant speed Annie can hold to her destination without ever passing one.Medium4MathImplementation+2No attempts yet5s512 MBJudgeable
Ample Syrup (Small)Choose K pancakes from at most 10 to stack largest radius on the bottom, maximizing the exposed surface area divided by pi.Medium4Brute forceSorting+2No attempts yet5s512 MBJudgeable
Taro's ShoppingGiven item prices and a budget, find the largest sum of two distinct items that does not exceed the budget.Medium4Two pointersSorting+1No attempts yet2s512 MBJudgeable
Frosh WeekGiven task durations and quiet-interval lengths, each between 100000 and 199999, pair tasks with intervals that fit them and maximize the number of completed tasks.Medium4GreedyTwo pointers+2No attempts yet4s512 MBJudgeable
ZigZagGiven K words and N letters, output for each letter the word starting with it that has been used fewest times, breaking ties alphabetically.Medium4SortingHash map+2No attempts yet2s64 MBJudgeable
Street LightsGiven existing street lights that each cover K metres to both sides, find the minimum number of extra lights needed to light every metre from 1 to N.Medium4GreedySorting+2No attempts yet1s64 MBJudgeable
How to Eat at a BuffetGiven a plate area and items with value per area and available area, pick fractions to maximize total value on the plate.Medium4GreedySortingNo attempts yet2s512 MBJudgeable
Milk MeasurementThree cows start at 7 gallons; apply N dated changes in chronological order and count the days on which the set of cows holding the top output changes.Medium4SimulationSorting+2No attempts yet2s512 MBJudgeable
Coloring IntervalsGiven n closed intervals with distinct endpoints, find the minimum number of colors so that overlapping intervals get different colors.Medium4SortingIntervals+2No attempts yet3s512 MBJudgeable
Best Matched PairGiven up to 1000 distinct integers, find the largest product of two whose product's decimal digits form a consecutive increasing run like 123; print -1 if none exists.Medium4ImplementationBrute force+2No attempts yet2s512 MBJudgeable
Out of PlaceGiven a row that came from a sorted row with one cow moved, find the minimum number of arbitrary swaps to sort it.Medium4SortingGreedy+1No attempts yet2s512 MBJudgeable
N and M (7)Given N distinct numbers and a length M, print every length-M sequence drawn from the numbers with repetition allowed, deduplicated and in increasing lexicographic order.Medium4BacktrackingRecursion+2No attempts yet1s512 MBJudgeable
N and M (8)Given N distinct natural numbers and a length M, print all non-decreasing sequences of length M drawn from the numbers, in lexicographic order.Medium4BacktrackingSorting+1No attempts yet1s512 MBJudgeable
N and M (9)Given N numbers (with duplicates) and length M, print every distinct length-M selection in increasing lexicographic order, using each copy at most once.Medium4BacktrackingSorting+1No attempts yet1s512 MBJudgeable
N and M (11)Given N numbers and a length M, list every length-M sequence drawn from the numbers, allowing repeats, in increasing lexicographic order without duplicates.Medium4BacktrackingRecursion+2No attempts yet1s512 MBJudgeable
N and M (12)Given N numbers and a length M, list all non-decreasing length-M sequences drawn from the numbers with repetition, in lexicographic order.Medium4BacktrackingSorting+2No attempts yet2s512 MBJudgeable
HoofballSort cows by position, then find the minimum number of starting balls so every cow receives the ball at least once under the nearest-cow passing rule.Medium4SortingGraph+1No attempts yet2s512 MBJudgeable
Lemonade LineGiven each cow's maximum tolerated queue length, choose an arrival order that minimizes how many cows end up waiting in line.Medium4GreedySorting+2No attempts yet2s512 MBJudgeable
Hook or Be HookedEach polygon has a squared radius equal to its farthest vertex from the origin; find the K-th smallest such value and print it with two decimals.Medium4GeometrySorting+2No attempts yet1s512 MBJudgeable
Au au ua ui ya!!Given N segments [x, y] already sorted by x, compute the total length covered by their union on the number line.Medium4IntervalsSorting+2No attempts yet2s512 MBJudgeable
Drawing ArrowsEach point shoots an arrow to the nearest same-colored point; find the total length of all N arrows. Points are given unsorted, so sort them by position first.Medium4SortingHash map+2No attempts yet2s512 MBJudgeable
Drawing ArrowsEach point shoots an arrow to the nearest same-colored point; compute the total length of all arrows.Medium4SortingHash map+2No attempts yet1s256 MBJudgeable
SunflowersGiven an N by N grid that is a 90-degree rotation of an unknown valid table, recover the original table.Medium4ImplementationMatrix+2No attempts yet2s512 MBJudgeable
Voronoi VillagesGiven N village positions on a line, find the smallest finite Voronoi neighbourhood size and print it with one decimal digit.Medium4SortingGeometry+2No attempts yet2s512 MBJudgeable
You Are Fired!Pick at most k employees whose salaries sum to at least d, minimizing the number fired, or report that it cannot be done.Medium4GreedySorting+1No attempts yet2s512 MBJudgeable
HackathonPartition N students into the fewest teams so each student's team size does not exceed their limit Xi.Medium4GreedySorting+1No attempts yet2s512 MBJudgeable
SpaceshipReorder n enemy powers so that the last one equals the sum of all the others.Medium4MathSorting+2No attempts yet2s512 MBJudgeable
Very Important PersonsAssign guest numbers 1 to nm to an n by m hall so seat (1,1) holds nm and numbers decrease with Manhattan distance from that seat.Medium4SortingMath+2No attempts yet2s512 MBJudgeable
Least Common MultipleGiven two irreducible fractions, find the smallest positive irreducible fraction divisible evenly by both, writing it in lowest terms.Medium4MathNumber theory+1No attempts yet2s512 MBJudgeable
Drawing LinesGiven N segments on a number line, find the total length of their union, counting overlaps once and printing it as an integer.Medium4SortingIntervals+2No attempts yet1s256 MBJudgeable
Planet ConnectionGiven a complete symmetric cost matrix, find a minimum spanning tree connecting all planets and output its total maintenance cost.Medium4Minimum spanning treeGraph+2No attempts yet1s256 MBJudgeable
SnakebirdGiven N fruits at heights h_i and a snake of length L, grow by eating any fruit of height at most the current length and output the maximum length reached.Medium4GreedySorting+1No attempts yet1s128 MBJudgeable
Function to Find the K-th NumberGiven an array of up to 5,000,000 integers and 1-based K, return the element at position K after sorting the array ascending.Medium4SortingBrute forceNo attempts yet0.2s512 MBJudgeable
Make the Largest NumberGiven up to 1000 non-negative integers, order the pieces so their concatenation is the largest possible number, and print it without leading zeros.Medium4GreedySorting+1No attempts yet2s512 MBJudgeable
Heroes of the Storm ProgamerGiven N character levels and a total increase K, raise levels to maximize the minimum of the chosen sequence.Medium4GreedySorting+1No attempts yet2s512 MBJudgeable
A Study on GroupsSplit the N integers into M groups whose sizes differ by at most one, then compute the smallest and largest possible sums of the group minima.Medium4ArrayGreedy+2No attempts yet1s512 MBJudgeable
InflationPair canister amounts with balloon sizes 1 to n so the minimum fill fraction is as large as possible without exceeding any capacity.Medium4GreedySortingNo attempts yet2s512 MBJudgeable
Judging DivisionalsGiven ranked teams with a division and university, apply two selection steps with university limits and output the 12 advancing teams by rank.Medium4SimulationImplementation+2No attempts yet1s512 MBJudgeable
LazylandEach of n workers wants one of k jobs and costs b_i to reassign. Keep one worker per chosen job and reassign the cheapest extras to cover every missing job. Return the minimum total cost.Medium4GreedySorting+1No attempts yet2s512 MBJudgeable
Contest SettingCount the ways to choose k problems whose difficulties are all distinct, given n problems and their difficulty values, modulo 998,244,353.Medium4MathCombinatorics+2No attempts yet1s512 MBJudgeable
Finding LoveSimulate sliding contests of M people, each eliminating one person at rank V, then print the last M-1 skills sorted ascending.Medium4SimulationSorting+2No attempts yet1s256 MBJudgeable
Digits Are Not Just CharactersCompare each name with s0 by splitting into letter and number items, then output "-" if it sorts before s0 or "+" otherwise.Medium4StringSorting+1No attempts yet2s512 MBJudgeable
PismoGiven an array of N integers, find two positions L < R minimizing the difference between the maximum and minimum of the subarray A[L..R].Medium4ArraySorting+1No attempts yet1s512 MBJudgeable
The Bucket ListGiven N milking intervals, each needing a fixed number of buckets, find the smallest labels FJ's greedy allocation ends up using across all cows.Medium4SimulationSorting+2No attempts yet2s512 MBJudgeable
Are You Listening?Given your point and n listening circles, find the largest radius centered there overlapping at most two of them; output the floor of it, or 0 if three already cover you.Medium4GeometryMath+2No attempts yet2s512 MBJudgeable
Two ArraysFor each element of A, find the element of B closest in value (smallest on ties) and print the sum of these chosen values.Medium4Binary searchSorting+2No attempts yet2s512 MBJudgeable
Cipher DecoderCheck whether the multiset of integers in the ciphertext matches the multiset of character codes of the given plaintext.Medium4Hash mapSorting+2No attempts yet1s512 MBJudgeable
Lining UpGiven N lines of 5 people each, decide whether everyone can pass through a single LIFO waiting area in increasing ticket order.Medium4StackSimulation+2No attempts yet1s512 MBJudgeable
Overflowing FandomGiven N intervals during which fans are at school, find the minimum length of a single visit window that meets every interval.Medium4IntervalsGreedy+2No attempts yet1s256 MBJudgeable
Badugi PokerGiven six distinct cards, each with a number 1 to 15 and a color, sort all 15 pairs by the ranking rules and print the winner first.Medium4SortingImplementation+2No attempts yet1s256 MBJudgeable
StreetlightsGiven N integer points, decide whether for every pair (xi,yi), (xj,yj) the two reflected points (xi,yj) and (xj,yi) are also present.Medium4Hash mapSorting+2No attempts yet0.5s256 MBJudgeable
And the Winner Is... Ourselves!Given 11 problems that are all solved, choose the solving order that minimizes total penalty, where each problem contributes its finish time plus 20 times its wrong submissions.Medium4GreedySorting+2No attempts yet4s1024 MBJudgeable
Cap SizeGiven cap sizes tried on with fit feedback, count how many untried sizes could still fit, or report inconsistent feedback.Medium4ImplementationSorting+2No attempts yet2s512 MBJudgeable
Pocket MoneyChoose banknotes from the wallet so the total is even and as large as possible, using any subset; print NIESTETY if only odd totals are reachable.Medium4GreedyMath+2No attempts yet2s512 MBJudgeable
Dome ConstructionGiven n points in 3D with non-negative y, find the minimum radius of a dome (hemisphere on the xz-plane) that contains at least k of them.Medium4Binary searchGeometry+2No attempts yet2s512 MBJudgeable
Feeding SealsEach volunteer can carry one or two buckets as long as their combined weight stays within capacity c. Find the minimum number of volunteers needed to move all buckets.Medium4GreedyTwo pointers+2No attempts yet2s512 MBJudgeable
222-PoolingRepeatedly replace each 2x2 block of an NxN matrix with its second largest value until one number remains, and print it.Medium4ImplementationSimulation+2No attempts yet1s256 MBJudgeable
Baba is RabbitGiven commands of the form p is q, find all objects reachable from Baba by applying one or more commands, printed in lexicographic order.Medium4GraphDFS+2No attempts yet1s512 MBJudgeable
Hardware SalesGiven three lists of (item ID, units) purchases, count items whose total units reach 20 or more in all three stores, printing IDs in first-appearance order.Medium4Hash mapImplementation+2No attempts yet1s512 MBJudgeable
Problem ClassificationCount exact whole-word occurrences of each category's keywords in a statement, then print the categories with the highest total count in lexicographic order.Medium4Hash mapString+2No attempts yet1s512 MBJudgeable
The New Year's BellGiven an N by M grid of who heard each bell ring, decide whether some distance thresholds R can produce exactly this pattern.Medium4SortingGreedy+2No attempts yet1s512 MBJudgeable
AntsGiven N integers, some negative or very large, find the smallest nonnegative integer that does not appear among the valid nonnegative values.Medium4ArrayHash map+2No attempts yet2s512 MBJudgeable
Hiding NutsGiven N grid points, pick the one minimizing the sum of Manhattan distances to all other points, breaking ties by smallest X then smallest Y.Medium4MathBrute force+2No attempts yet1s512 MBJudgeable
AntennaGiven positions of houses on a line, pick the house position that minimizes the total distance to all houses, choosing the smallest such position on ties.Medium4SortingMath+2No attempts yet1s256 MBJudgeable
LTBLRead match results between two teams, accumulate points, wins, draws, losses, and goals, then print the league table sorted by the six tiebreak rules.Medium4ImplementationSorting+2No attempts yet2s512 MBJudgeable
Multiverse IITwo universes are equal when their planet sizes give the same ordering and tie pattern; count pairs of the M universes that match.Medium4SortingHash map+1No attempts yet2s512 MBJudgeable
Coordinate CompressionFor each of N coordinates, output the number of distinct values smaller than it, which is its rank under coordinate compression.Medium4SortingHash map+2No attempts yet2s512 MBJudgeable
LadderGiven n sticks that can only be shortened, decide whether two can become length x and k others length y.Medium4GreedySorting+2No attempts yet2s64 MBJudgeable
On Becoming the Strongest Competitive Programmer After 200 Years of SeclusionGiven contests in fixed order, each with a prize cap and a prize amount, decide whether Yeondu can skip at most one contest while never exceeding the running cap.Medium4GreedyImplementation+2No attempts yet1s1024 MBJudgeable
Cyber Opening CeremonyGiven start, end, and stream-end times plus chat logs, count members who chatted at or before the start and again between the end and stream-end.Medium4Hash mapImplementation+2No attempts yet1s1024 MBJudgeable
BeadmanGiven counts of N bead types, repeatedly remove one bead of each of two different types; find the minimum number of beads that can remain.Medium4GreedyMath+2No attempts yet1s1024 MBJudgeable
Cow-abunga!Given at most 9 cow weights, choose M of them and print every prime number that appears as a subset sum, in increasing order.Medium4Brute forceCombinatorics+2No attempts yet1s1024 MBJudgeable
Best PlaceGiven N points, find integer coordinates (X, Y) that minimize the sum of Manhattan distances from the point to every participant.Medium4SortingMath+2No attempts yet1s512 MBJudgeable
FractificationGiven four positive integers, arrange them into two fractions a/b + c/d so the sum is as small as possible, and print the arrangement.Medium4GreedySorting+2No attempts yet2s512 MBJudgeable
DunesEach gust adds +x to l and then alternates signs up to r; answer m queries for the final height at given positions.Medium4ArrayPrefix sum+2No attempts yet2s512 MBJudgeable
Sleep PatternGiven weekday sleep intervals on a Mon-Fri timeline, compute the minimum weekend hours needed so total weekly sleep reaches T, or report that even 48 hours is not enough.Medium4ImplementationMath+2No attempts yet1s1024 MBJudgeable
Base-36 NumberPick K base-36 digit symbols to replace with Z across N numbers so their sum is maximized, then output that sum in base 36.Medium5GreedyMath+2No attempts yet2s128 MBJudgeable
Cargo LoadingGiven crane weight limits and box weights, find the minimum minutes to load all boxes with one box per crane per minute, or -1 if impossible.Medium5GreedySorting+1No attempts yet2s128 MBJudgeable
Maximum SumAssign digits 0-9 to letters A-J that encode N numbers so that the sum of the numbers is maximized while no number has a leading zero.Medium5GreedyMath+2No attempts yet2s128 MBJudgeable
Four PrimesWrite a program that finds four prime numbers whose sum equals a given natural number N, or reports -1 if impossible.Medium5Number theoryMath+2No attempts yet2s128 MBJudgeable
Tablature TranspositionConvert a fretted-instrument tablature to a different instrument's tuning, transposing each note and picking the highest-pitched available string for it.Medium5GreedySimulation+2No attempts yet2s128 MBJudgeable
Yogurt Expiration DatePick k yogurts with maximum total amount, break ties by minimizing the chance at least one is defective, and print that incident probability as a percentage.Medium5GreedySorting+2No attempts yet2s128 MBJudgeable
LibraryFind the minimum total steps for a librarian starting at 0 to deliver books to their positive or negative integer positions while carrying at most M books per trip.Medium5GreedySorting+2No attempts yet2s128 MBJudgeable
Collecting GemsGiven N gem weights and M bags of capacity C, determine the maximum number of gems that can be packed into the bags without exceeding capacity.Medium5GreedySortingNo attempts yet2s128 MBJudgeable
DuelMatch N Team A fighters against N Team B fighters to maximize points, where a win scores 2, a tie scores 1, and a loss scores 0.Medium5GreedySorting+1No attempts yet2s128 MBJudgeable
Sejun and Sebi's WarGiven two armies whose weakest soldier dies each round (ties killing Sebi's soldier first), determine which side's soldier survives last.Medium5GreedySimulation+2No attempts yet2s128 MBJudgeable