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,802 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Box PackingGiven box sizes in order, find the longest subsequence where each box is strictly smaller than the next, counting boxes in the pile.Medium4Dynamic programmingBinary search+2No attempts yet2s512 MBJudgeable
Jump JumpGiven jump distances on a row of n stones, count how many stones are reachable from a starting stone via left or right jumps that stay on the bridge.Medium4GraphBFS+2No attempts yet2s512 MBJudgeable
Stretch Rope (Small)N is at most 10, so enumerate subsets of bands and find the cheapest subset whose summed intervals contain L and whose total price is within M.Medium4Brute forceArray+2No attempts yet5s512 MBJudgeable
Hoof, Paper, Scissors (Silver)Given FJ's sequence of N gestures, find the most games Bessie can win if she switches her own gesture at most once.Medium4Prefix sumBrute force+1No attempts yet2s512 MBJudgeable
Cow TippingGiven an N by N grid of 0s and 1s, find the minimum number of upper-left rectangles to toggle so all cells become 0.Medium4GreedyArray+2No attempts yet2s512 MBJudgeable
Why Did the Cow Cross the Road IIGiven a 52-character string where each of the 26 letters appears twice, count pairs of letters whose chord crossings force their paths to intersect.Medium4ArrayImplementation+2No 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
Wookje Is a Devoted Son!!Given edge costs of a cycle of n villages, find the minimum total cost for three travelers starting at one village to collectively visit every village.Medium4GreedyImplementation+2No attempts yet2s512 MBJudgeable
Rolling a DiceRoll a dice on an N by M grid, updating the cell under it and the dice faces each move, and print the top face after every successful move.Medium4SimulationImplementation+1No attempts yet2s512 MBJudgeable
Robot Vacuum CleanerSimulate a robot vacuum that cleans cells, rotating counterclockwise and moving forward or backward, and count how many cells it cleans before stopping.Medium4SimulationImplementation+2No attempts yet2s512 MBJudgeable
Tofu GameSimulate the tofu game: each shouted block number selects the next reference, and print which person holds it, stopping at the terminal value.Medium4SimulationImplementation+2No attempts yet2s128 MBJudgeable
Club Room Project (Large)For each action, remove all walls between rooms x and y; print how many connected room blocks remain.Medium4Union-findArrayNo attempts yet1s512 MBJudgeable
Wookje's Dinner WheelGiven a sequence where each menu number appears exactly twice, find the maximum number of values seen once but not yet seen twice at any point.Medium4ArrayHash map+2No attempts yet2s256 MBJudgeable
Juno hates birds!!Given an n by m grid of numbers, remove the row or column containing the most digit 9s (ties broken by scanning order) and count the remaining 9s.Medium4ArrayImplementationNo attempts yet2s256 MBJudgeable
A Taste of QueriesGiven a sequence of n numbers, process q queries that either report a range sum and then swap two positions, or report one range sum minus another.Medium4ArrayPrefix sum+2No attempts yet2s256 MBJudgeable
Stephen QuerySimulate N rounds of survival rock paper scissors and report the longest number of consecutive wins by any single player.Medium4SimulationImplementation+1No 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
Venue Rental (Small)Given up to 100 axis-aligned rectangles, find the area of the union of all rectangles.Medium4ArrayImplementation+2No attempts yet2s256 MBJudgeable
Pizza BoxesGiven a grid of distinct pile heights, find how many boxes can be removed while keeping the per-row and per-column maxima unchanged.Medium4ArrayGreedy+2No attempts yet1s512 MBJudgeable
GearsSimulate K gear turns; each turn makes a named gear rotate and may propagate to neighbors when the touching poles differ, then print a weighted score from the four top teeth.Medium4ImplementationSimulation+1No attempts yet2s512 MBJudgeable
Sum of all pairwise productsGiven n integers, compute the sum of x_a * x_b over all pairs with a < b.Medium4MathPrefix sum+2No attempts yet2s512 MBJudgeable
Sogang GroundGiven a weighted undirected graph, find a region whose total item count within distance m is largest.Medium4GraphShortest path+1No attempts yet1s128 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
Forest PictureDraw an ASCII forest on an M by M canvas from tree or stump coordinates, clipping shapes that fall outside and framing the result with asterisks.Medium4ImplementationSimulation+2No attempts yet2s512 MBJudgeable
Dark Ride with MonstersGiven a permutation of misplaced monsters, find the minimum number of swaps needed to sort all monsters into their correct chambers.Medium4ArrayGraph+2No attempts yet5s512 MBJudgeable
Complete Naebbirac's sequenceGiven a multiset of values 1..K, find the single add, remove, or replace operation that makes every value appear equally often.Medium4ArrayHash map+1No attempts yet1s1024 MBJudgeable
Byte Me!Given N data bytes and a parity byte, find the parity type, the one data byte with wrong popcount parity, and the flipped bit position.Medium4Bit manipulationImplementation+1No attempts yet2s512 MBJudgeable
Wet Rock Peg PlanSimulate a sequence of peg placements and removals on a dependency DAG, tracking peak peg count and the first wet-rule violation.Medium4SimulationGraph+2No attempts yet2s512 MBJudgeable
Olympiad PizzaContestants queue for pizza slices; each takes one slice per turn and rejoins the back if still hungry. Report the second each finishes.Medium4QueueSimulation+2No 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
Frosting on the CakeGiven vertical stripe widths A and horizontal stripe heights B, find the total area of each of the three colors where each cell's color is (i+j) mod 3.Medium4ArrayMath+2No attempts yet5s512 MBJudgeable
The Bovine ShuffleGiven a permutation describing one shuffle and the cow order after three shuffles, recover the original order before the shuffles.Medium4ArrayImplementation+2No 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
Maximum of A[j]-A[i]+A[l]-A[k]Given an array, choose four increasing indices i<j<k<l maximizing A[j]-A[i]+A[l]-A[k].Medium4Dynamic programmingArray+1No attempts yet2s512 MBJudgeable
WindowGiven N panes of size W by H, slide odd-indexed panes east and even-indexed panes west by given distances, then compute the uncovered window area.Medium4ArraySimulation+2No attempts yet2s512 MBJudgeable
TimoviKids are dealt into N teams in a bouncing 1..N..1 order, K per visit, until fewer than K remain; report each team's final count.Medium4MathSimulation+2No attempts yet1s64 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
Divisor PairsGiven n integers, count ordered pairs (i, j) with i != j such that a_i divides a_j.Medium4MathArray+2No attempts yet2s512 MBJudgeable
Word Search in a GridDecide whether a word appears in a grid along a straight line of neighboring cells in any of the eight directions.Medium4ArraySimulation+2No attempts yet2s512 MBJudgeable
JujisuGiven an N by M grid of populations, answer K queries for the sum of people inside each requested rectangle.Medium4Prefix sumArray+2No attempts yet2s512 MBJudgeable
Taming the HerdGiven a partial daily log of days-since-breakout values with a breakout on day 1, find the minimum and maximum possible breakouts.Medium4GreedyArray+2No 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
SegmentationTrack visits per user over time and answer queries by mapping each user's recency and frequency to one of 12 RF segments.Medium4Hash mapImplementation+2No attempts yet1s1024 MBJudgeable
Aku NegarakuFor each N and M, simulate Josephus elimination around a circle and report the last remaining trainee's number.Medium4SimulationArray+1No attempts yet3s512 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
ÜberwatchGiven a sequence of opponent counts over n time slices and a cooldown m, choose firing times at least m slices apart to maximize total opponents defeated.Medium4Dynamic programmingArray+2No attempts yet2s512 MBJudgeable
It's Time for a MontageEach day every hero gains 1 power; find the minimum number of days until the heroes win the ordered rival showdown.Medium4ImplementationGreedy+2No attempts yet2s512 MBJudgeable
Dormvival GamesSimulate M weeks of adjacent room swaps driven by weekly merit and demerit scores, tracking how often the gap between Hong and Cho stays within B.Medium4SimulationImplementation+1No attempts yet0.5s128 MBJudgeable
Human-Computer InteractionCount how often a given lowercase letter appears inside each query interval [l, r] of a fixed string S, answering up to 200,000 queries.Medium4Prefix sumArray+1No attempts yet1s256 MBJudgeable
Gun ControlGiven each lawmaker's defeat cost and compromise value, pick a subset whose costs sum to more than B with minimum total compromise.Medium4Dynamic programmingArrayNo attempts yet2s512 MBJudgeable
Gahui and the 3-Step High NoteGiven a sequence of notes and an arithmetic progression with first term A and difference D, find the largest number of terms of the progression that appear as a subsequence in order.Medium4GreedyArray+2No attempts yet1.5s256 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
ZamjenaGiven two arrays of numbers and variables, decide if one assignment of integers to variables makes corresponding positions equal. Consistent positions give constraints; any conflict answers NE.Medium4Hash mapImplementation+1No attempts yet1s64 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
Hard Prime FactorizationFactor each of up to one million numbers up to 5,000,000 and print its prime factors in increasing order.Medium4Number theoryArray+2No attempts yet2s512 MBJudgeable
Binary KingdomMaintain a binary array under requests that set a cell to 1 and report how many runs of consecutive 1s exist.Medium4ArrayImplementation+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
LapsGiven per-minute track positions from a monotone run on an n-metre loop, find the smallest possible total forward distance modulo n in laps.Medium4ArrayMath+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
Generic QueriesGiven an array and range queries, compute each interval XOR and output the XOR of all answers mixed with the given k values.Medium4Prefix sumBit manipulation+2No attempts yet2.5s512 MBJudgeable
Gyeol! Hap!Score a Set-like game by checking each called triple against the hap rule and each gyeol against remaining uncalled haps.Medium4Brute forceImplementation+1No attempts yet1s256 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 Ups and Downs of InvestingCount price peaks needing n rising and n falling days and valleys needing m falling and m rising days.Medium4ArrayImplementation+1No attempts yet2s512 MBJudgeable
BombermanSimulate Bomberman's bomb placement and explosion cycle on a grid and print the state after N seconds.Medium4SimulationImplementation+2No attempts yet2s512 MBJudgeable
Surface AreaGiven a grid of cube stack heights, compute the total surface area of the resulting 3D figure, including the top, bottom, and exposed side faces.Medium4ImplementationMath+2No attempts yet1s512 MBJudgeable
Block PlayEach tower can be changed to any height at least 1 in one minute. Find the fewest towers to change so that consecutive heights differ by K.Medium4MathImplementation+2No attempts yet2s512 MBJudgeable
Omok: Can Kyusagwa Win?On a 10x10 omok board, decide whether Kyusagwa, moving next with X stones, can place one stone to make five in a row.Medium4ImplementationSimulation+2No attempts yet2s512 MBJudgeable
Tabs vs SpacesFor each of up to 366 days, count tab and space guests from N intervals, then report occupancy days, peak headcount, fight-free days, peak headcount among those, and the longest stay length.Medium4ArraySimulation+2No attempts yet2s512 MBJudgeable
Sequence and Queries 21Support range-add updates and point queries on an array of up to 100,000 elements with up to 100,000 operations.Medium4ArrayPrefix sum+1No attempts yet2s512 MBJudgeable
JarvisPick one integer X added to every factory frequency so that the count of indices with Ai + X = Bi is as large as possible.Medium4Hash mapArray+2No attempts yet1s512 MBJudgeable
SortingGiven an array, count how many single elements can be removed so that the remaining N-1 elements are in nondecreasing order.Medium4ArrayImplementation+2No attempts yet1s512 MBJudgeable
Three FriendsGiven a sparse undirected graph, find three mutually adjacent vertices minimizing the sum of their degrees excluding the other two chosen vertices.Medium4GraphBrute force+2No attempts yet2s512 MBJudgeable
Array PlayGiven an N by N grid and M rectangle-add operations, output the final sum of each row and each column.Medium4Prefix sumArray+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
Magician Nam JeonghunApply a sequence of up to 10 million suit-changing and rotation commands to 26 cards, printing the arrangement whenever a show command appears.Medium4ImplementationString+2No attempts yet1s256 MBJudgeable
Good Pizza, Great PizzaGiven N points, find the area of the smallest 45-degree tilted square (rhombus) that contains all of them.Medium4GeometryMath+2No attempts yet1s256 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
PatternGiven a sequence of grid points, decide whether it is a valid Android unlock pattern under the no-repeat and no-skipped-point rules.Medium4ImplementationSimulation+2No attempts yet1s512 MBJudgeable
Sequence and Shift QueriesMaintain a sequence under point additions and cyclic rotations by s positions to the right or left, then print the final array.Medium4ArrayImplementation+2No attempts yet1s256 MBJudgeable
Inquiry ISplit the array into a prefix and a suffix at some index k; maximize the sum of squares of the prefix times the sum of the suffix.Medium4Prefix sumArray+2No attempts yet3s512 MBJudgeable
City of LightsGiven N lights initially on and k toggles where toggle i flips every multiple of i, find the maximum number of lights that are off at any point during the sequence.Medium4ArrayImplementation+2No attempts yet1s512 MBJudgeable
Bus LogicGiven a starting stop and bus routes as bit strings of length s, find the maximum number of other stops reachable by choosing exactly one bus that serves the starting stop.Medium4Bit manipulationImplementation+2No attempts yet1s512 MBJudgeable
Last WordGiven a string and a sequence of substring(start, length) operations, output the characters that survive after all operations are applied in order.Medium4StringSimulation+2No attempts yet1s512 MBJudgeable
On-Screen KeyboardGiven a grid keyboard with a highlighted cell, find the total minimum button presses to type a string, where each character's cost is the Manhattan distance plus one for OK.Medium4ImplementationArray+2No attempts yet2s512 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
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
Rotating DisksSimulate T rounds of rotating selected concentric disks, erasing adjacent equal numbers, or adjusting all numbers toward the average, then report the final sum.Medium4SimulationImplementation+2No attempts yet1s512 MBJudgeable
Diamonds Are for EversDecode a message written into a square grid along nested diamond diagonals, given the row-by-row concatenation of all cells.Medium4ImplementationMatrix+2No attempts yet1s512 MBJudgeable
Flight TurbulenceA permutation maps each seat to the passenger sitting there; count how many passengers shift when one passenger demands their assigned seat.Medium4ArraySimulation+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
Integer DivisionCount pairs of indices whose values give the same quotient when both are divided by d using floor division.Medium4Hash mapMath+1No attempts yet2s512 MBJudgeable
Tired TerryGiven a circular sleep pattern of length n, count for how many seconds i the preceding p seconds contain fewer than d seconds of sleep.Medium4Sliding windowPrefix sum+2No attempts yet1s512 MBJudgeable
Short SellGiven N daily prices and a daily interest K per 100 borrowed coins, pick a borrow day and a repay day to maximize profit.Medium4ArrayPrefix sum+2No attempts yet1s512 MBJudgeable