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,178 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
DiamondsFor each count Pmin, find the smallest radius whose worst-case center covers at least Pmin points, then the best coverage at that radius.Medium6GeometryPrefix sum+2No attempts yet1s128 MBJudgeable
TicketsSplit L pages of non-increasing popularity into D contiguous channel blocks to minimize the popularity-weighted sum of within-block delay positions, breaking ties by the lexicographically smallest block boundaries.Medium6Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
SeriesWrite all integers from n to m as one digit string, sort the digits descending, and report the k-th digit, or NAV if the string is shorter.Medium6MathImplementation+2No attempts yet1s128 MBJudgeable
DragonPick two disjoint blocks of at most K consecutive heads each in a row of N heads to maximize the total fire power removed.Medium6Dynamic programmingPrefix sum+2No attempts yet1s1024 MBJudgeable
Food CompositionGiven ingredients in decreasing order, some with stated percentages, find the minimum and maximum possible percentage for each, or report impossibility.Medium6GreedyMath+2No attempts yet1s1024 MBJudgeable
LawnmowerSimulate a lawn that grows each morning and is mowed b_j times per day, reporting the total remaining grass height after each day.Medium6SortingPrefix sum+2No attempts yet1s1024 MBJudgeable
Optimal KeypadSplit a 30-character alphabet tape into 12 labeled pieces to minimize total keystrokes for a word dictionary, printing the lexicographically smallest optimal cut string.Medium6Dynamic programmingPrefix sum+1No attempts yet1s128 MBJudgeable
AdvertisementPlace the fewest advertisements so every jogger's interval of billboards contains at least min(K, length) of them.Medium6GreedyIntervals+2No attempts yet1s128 MBJudgeable
Graveyard DesignFind all runs of consecutive positive integers whose squares sum to a given n up to 10^14, and list each run in order of its smallest element.Medium6Two pointersMath+2No attempts yet2s64 MBJudgeable
Sum of Consecutive PrimesFor each query set of counts, find the smallest prime expressible as a sum of exactly n_i consecutive primes for every given n_i.Medium6Number theoryPrefix sum+2No attempts yet2s128 MBJudgeable
Castle WallsGiven blue and red hooks with distinct line positions, count blue-red pairs whose endpoints satisfy the crossing inequality.Medium6SortingPrefix sum+1No attempts yet1s128 MBJudgeable
ProbeGiven range-sum probe results on a length-K binary road, find the lexicographically smallest object placement satisfying all of them, or NONE.Medium6ArrayPrefix sum+2No attempts yet1s128 MBJudgeable
Burger, French Fries, Soft DrinkCount the ways to cut a B/F/S stream into N consecutive blocks where every block has equal positive counts of each letter, or report Impossible.Medium6Dynamic programmingPrefix sum+2No attempts yet1s128 MBJudgeable
The Adventure in Panda Land Part I: Panda NumberSum the bamboo-stick counts of the Panda numeral representation for every integer from A to B, including negatives and zero.Medium6MathImplementation+1No attempts yet1s128 MBJudgeable
Pizza Delivery ScheduleGiven recorded pizza deliveries by week and weekday, find the fixed weekly-cycle schedule of period 1 to 4 weeks that minimizes mismatched days.Medium6Brute forceImplementation+2No attempts yet1s128 MBJudgeable
SignalGiven sequence s and a pattern f, find the smallest starting position where f occurs as a contiguous block that can be one of exactly k fragments of lengths in [a,b].Medium6String matchingGreedy+1No attempts yet1s128 MBJudgeable
A Journey to MarsFor each station on a circle, decide whether starting there with two direction choices lets Byteazar complete a full loop without running out of fuel.Medium6GreedyPrefix sum+1No attempts yet3s512 MBJudgeable
One-sequenceFind the lexicographically smallest walk of length n starting at 0 with +/-1 steps whose total sum is S, or report that none exists.Medium6GreedyImplementation+2No attempts yet1s128 MBJudgeable
TeddiesCount the distinct safe arrangements of up to 152 teddies in four models so that no three consecutive share a letter or a digit, modulo 1000000.Medium6Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable
Fairy LightsFor each pressed button, compute the limiting fraction of integers whose final color is that button's color.Medium6MathNumber theory+2No attempts yet1s128 MBJudgeable
PebblesPiles are sorted; a move reduces one pile without breaking the order. Determine whether the first player wins.Medium6Game theoryGreedy+1No attempts yet3s512 MBJudgeable
Two CakesTwo cakes must be built layer by layer from two given permutations, using one dedicated worker per layer type; find the minimum total time.Medium6GreedyArray+2No attempts yet4s128 MBJudgeable
CoinsGiven a string of O and R tosses, find the longest substring where the number of O equals k times the number of R.Medium6Prefix sumHash map+1No attempts yet1s128 MBJudgeable
Crossing DiagonalsCount crossing pairs among m chosen diagonals of a regular n-gon, ignoring diagonals that only share a vertex.Medium6SortingPrefix sum+1No attempts yet1s128 MBJudgeable
SafeGiven a word and one rotation offset per wheel, find the minimum total turns to make all wheels display the same word.Medium6StringImplementation+2No attempts yet1s128 MBJudgeable
SheetsStarting from sheets 1..n, each step merges the first k into their sum appended at the end; report the sum written during the r-th step.Medium6MathSimulation+2No attempts yet1s128 MBJudgeable
InversionsCount permutations of size n that have exactly k inversions, modulo 30011, using the Mahonian number recurrence with a sliding window over prefix sums.Medium6Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
Speed LimitsGiven speed limits on intervals of a highway plus a car's top speed, pick the single limit whose removal maximizes total satisfaction (distance times speed).Medium6ArrayPrefix sum+2No attempts yet1s128 MBJudgeable
PolynomialGiven a degree-n polynomial's values at 0 through n, compute its value at n+1.Medium6MathPrefix sum+1No attempts yet1s128 MBJudgeable
MapGiven an n by m grid and q queries, each comparing two h by w subrectangles, decide if at most k corresponding cells differ.Medium6Prefix sumMatrix+1No attempts yet1s128 MBJudgeable
RaceFind the length-m segment of the road that minimizes total riding time under piecewise constant speed limits.Medium6Sliding windowPrefix sum+1No attempts yet1s512 MBJudgeable
AquaparkSum the grid values inside the Manhattan diamond of radius l_i around each lifeguard.Medium6Prefix sumMatrixNo attempts yet1s512 MBJudgeable
Triangle SticksThe program keeps the largest subset of up to 30000 sticks with lengths 1 to 500 in which any three sticks form a non-degenerate triangle.Medium6SortingBrute force+1No attempts yet1s512 MBJudgeable
Bajhattan PanoramaGiven row maxima and column maxima, test whether any grid fits them and compute the largest possible total height.Medium6GreedySorting+1No attempts yet1s128 MBJudgeable
DominoChoose the smallest chain from the first to the last domino where each kept tile is taller than the distance to the next kept tile.Medium6GreedyPrefix sum+1No attempts yet1s128 MBJudgeable
ClocksPick one time every clock can show so the total forward movement from the current readings is as small as possible.Medium6SortingPrefix sum+1No attempts yet1s128 MBJudgeable
CookiesBoth players take the best remaining cookie in turn with Zbyszek starting, and you add at most one cookie of any quality to minimize his total minus Hektor's.Medium6SortingPrefix sum+1No attempts yet2s128 MBJudgeable
Powerbase FormatCount how many integers in each query range lack a powerbase form d1^1+...+dL^L within the length bound using the given digits.Medium6BacktrackingDynamic programming+1No attempts yet1s128 MBJudgeable
Paper MapTry every horizontal and vertical shift of the fixed sheet grid and print the smallest number of sheets that covers all marked cells.Medium6Brute forcePrefix sumNo attempts yet3s128 MBJudgeable
CirclelandYou start at room R1 on a corridor cycle and visit every room, then leave through any exit while walking the shortest total corridor distance.Medium6GreedyPrefix sum+1No attempts yet1s256 MBJudgeable
Omar Loves CandiesFind the largest sum of any non-empty sub-rectangle in a grid whose rows and columns strictly increase.Medium6Prefix sumGreedy+1No attempts yet3s128 MBJudgeable
BitTorrentChoose the most files whose covering fixed-size pieces fit in the bandwidth budget, where a piece shared by files is paid once.Medium6Dynamic programmingPrefix sumNo attempts yet2s128 MBJudgeable
Building a Ski CourseFind the largest square stamp size that can repaint the given rough and smooth grid when later stamps cover earlier ones.Medium6GreedyPrefix sum+1No attempts yet1s128 MBJudgeable
SabotageRemove a contiguous block of middle machines, keeping the first and last, so the average output of the machines left is as small as possible.Medium6Binary searchPrefix sumNo attempts yet1s128 MBJudgeable
Fair PhotographyCows at distinct positions are white or spotted, and after repainting some white cows you need the widest interval with equal counts.Medium6Prefix sumHash map+1No attempts yet1s128 MBJudgeable
IOI ManjuChoose boxes and fill them with the priciest manju so packed value minus box cost is as large as possible.Medium6Dynamic programmingSorting+1No attempts yet1s256 MBJudgeable
OrchardPick one rectangle for Bert to minimize the bananas left outside it plus the apples inside it.Medium6MatrixPrefix sum+1No attempts yet2s512 MBJudgeable
Decreasing Sequences of PointsCount sequences of lattice points on the diagonals x+y=a_i with nondecreasing x and nonincreasing y.Medium6Dynamic programmingPrefix sumNo attempts yet1s256 MBJudgeable
Tinted Glass WindowN overlapping rectangles each add an integer tint to the area they cover, and you must find the total area whose summed tint is at least T.Medium6Prefix sumSorting+1No attempts yet1s256 MBJudgeable
King GruffFor each query, sum the shutdown costs of roads lying on some A to B path whose total length is at most D.Medium6Shortest pathSorting+1No attempts yet2s256 MBJudgeable
Quality of LivingFind the smallest median among all H by W subrectangles of a grid holding the numbers 1 to R times C.Medium6Binary searchPrefix sum+1No attempts yet5s256 MBJudgeable
Lift ProblemsDecide the lift stops for given per-floor student counts to minimize total annoyance from stops and skipped floors.Medium6Dynamic programmingPrefix sumNo attempts yet1s256 MBJudgeable
BricksSplit the run-length encoded brick row into the most contiguous blocks that all share one white-to-black ratio.Medium6GreedyPrefix sum+1No attempts yet6s256 MBJudgeable
Knapsack CollectionOver every starting slot, find the min, max, and average time to collect all bags from a rotating carousel when each pickup takes t units.Medium6SortingPrefix sum+1No attempts yet4s512 MBJudgeable
Christmas WheatMirko raises one shortest stalk to the next height and Slavko lowers one tallest stalk until two distinct heights remain; report the winner and both extremes.Medium6SortingPrefix sum+2No attempts yet1s32 MBJudgeable
Concatenating Parenthesis StringsDecide whether the given parenthesis strings can be ordered so their concatenation forms a correct bracket sequence.Medium6GreedySorting+1No attempts yet2s128 MBJudgeable
JOI ParkPick a distance X from square 1 to minimize C times X plus the total length of roads not fully inside the X radius.Medium6Shortest pathSorting+1No attempts yet1s256 MBJudgeable
Maximum Average SegmentFind the largest average over all contiguous subarrays of length at least K and print it truncated to six decimals.Medium6Binary searchPrefix sumNo attempts yet1s64 MBJudgeable
Cow HopscotchCount paths from the top-left to the bottom-right cell that step strictly down and right onto a different value, modulo 1000000007.Medium6Dynamic programmingPrefix sum+1No attempts yet1s256 MBJudgeable
Picky EaterCut the convex polygon along one diagonal between nonadjacent vertices and eat the largest piece that contains no olive.Medium6GeometryBrute force+1No attempts yet1s512 MBJudgeable
Interval CompositionFind the maximum length L such that each of the two lowercase strings has a contiguous block of length L with the same letter counts.Medium6Prefix sumHash map+1No attempts yet1s256 MBJudgeable
Catching EggsCount the homes inside each of m axis-parallel rectangles and print the total over all days per test case.Medium6Prefix sumSorting+1No attempts yet5s256 MBJudgeable
Apples and BananasPick a path from the top left to the bottom right using right, down, and diagonal steps to maximize apples left below plus bananas left above.Medium6Dynamic programmingPrefix sumNo attempts yet1s256 MBJudgeable
Merging FilesCompute the cheapest way to merge consecutive chapter files when each merge costs the sum of the two parts.Medium6Dynamic programmingIntervals+1No attempts yet2s256 MBJudgeable
Railway TicketsCount station pairs where every leg has a free seat but no single seat stays free for the whole trip.Medium6IntervalsSorting+1No attempts yet1s256 MBJudgeable
Currency ConversionSchedule at most b bank exchanges to meet dated purchase needs while maximizing daily holding rewards minus trip costs.Medium6Dynamic programmingPrefix sumNo attempts yet1s256 MBJudgeable
Average Voodoo Doll PriceCount the contiguous runs of days whose average doll price is at least P.Medium6Prefix sumDivide and conquer+1No attempts yet2s64 MBJudgeable
Landscape ImprovedPlace up to n stones on a rocky skyline under pyramid support rules to push the highest peak as high as possible.Medium6Binary searchPrefix sumNo attempts yet1s256 MBJudgeable
UFOSimulate laser shots that each destroy up to R blocks at height h along one row or column, then find the P by P square holding the most surviving blocks.Medium6Segment treeSimulation+1No attempts yet2s256 MBJudgeable
Multi-pianoChoose a nonnegative step K so the walk that starts at the first pitch and moves by K on each rise or fall matches the true pitches in the most positions.Medium6Hash mapPrefix sum+1No attempts yet1s64 MBJudgeable
XorbonacciGiven the first K terms of an XOR recurrence, answer many queries asking for the XOR of terms l through r with indices up to 1e18.Medium6MathPrefix sum+1No attempts yet1s64 MBJudgeable
Max FlowCount how many of the K given tree paths pass through each stall and report the largest count.Medium6TreePrefix sum+1No attempts yet2s512 MBJudgeable
Fort MooFind the largest interior area of a grid rectangle whose border cells are all grass, with swamp allowed inside.Medium6Prefix sumBrute force+1No attempts yet2s512 MBJudgeable
Splitting the FieldCompute how much fenced area is saved by covering all points with two disjoint axis-aligned rectangles instead of one.Medium6SortingPrefix sum+1No attempts yet2s512 MBJudgeable
Round Robin SchedulerGiven each job's required seconds, compute its finishing time under a round robin scheduler that grants one second per turn in index order.Medium6SortingPrefix sum+1No attempts yet2s512 MBJudgeable
Smoothing Window (Small)Given sliding window sums of an unknown integer sequence, find the smallest possible range between its largest and smallest values.Medium6Binary searchIntervals+1No attempts yet5s512 MBJudgeable
Magical, Marvelous TourArnar picks a contiguous segment, Solveig claims the largest of the three parts it creates, and Arnar keeps the rest.Medium6Prefix sumTwo pointersNo attempts yet5s512 MBJudgeable
Magical, Marvelous TourArnar names a middle interval and Solveig keeps the richest of the three pieces, so compute the split that leaves Arnar the most transistors.Medium6Binary searchPrefix sumNo attempts yet5s512 MBJudgeable
Meet and Party (Large)Pick an invited home inside the given rectangles that minimizes the total Manhattan distance walked by all guests and report its coordinates and the sum.Medium6SortingPrefix sum+1No attempts yet5s512 MBJudgeable
Spinning Blade (Large)Find the largest K by K square, with its four corner cells removed, whose cell masses balance exactly about the square center.Medium6Prefix sumBrute forceNo attempts yet5s512 MBJudgeable
Increasing Speed LimitsGiven a sequence generated by a small recurrence, count strictly increasing subsequences by position, modulo 1000000007.Medium6Dynamic programmingSorting+2No attempts yet5s512 MBJudgeable
Number Sets (Large)Given an interval of consecutive integers and a threshold P, merge pairs sharing a prime factor of at least P, then count the remaining sets.Medium6Union-findNumber theory+2No attempts yet50s512 MBJudgeable
Gennady is smartMaintain counts on a hexagonal grid; each update adds 1 to all cells within distance r of (x, y), and queries ask for a single cell's value.Medium6Prefix sumMatrix+1No attempts yet2s256 MBJudgeable
UniversitiesOn a tree whose nodes are black or white with weighted happiness, find the maximum total weight of a path that contains equally many black and white nodes.Medium6TreePrefix sum+1No attempts yet1s1024 MBJudgeable
Building HeightsWith building 1 at height 0, adjacent heights differing by at most K, and M caps, find the maximum achievable height of any building.Medium6GreedyImplementation+2No attempts yet2s512 MBJudgeable
Time Travel and MultisetProcess insert, delete, and count operations on a time-indexed multiset, where each value's count at time t depends on prior operations with time at most t.Medium6Dynamic programmingBinary search+2No attempts yet2s512 MBJudgeable
Colorful Village 2For each query range in a nondecreasing brightness array, report how many times the most frequent value appears.Medium6ArrayBinary search+1No attempts yet2s512 MBJudgeable
Mountain ScenesCount vectors of w heights in [0,h] whose sum is at most n and which are not all equal, modulo 1e9+7.Medium6Dynamic programmingCombinatorics+2No attempts yet5s512 MBJudgeable
Divisors AgainFor each of up to 10 ranges of at most 1001 integers, find the number in [L, U] with the most divisors.Medium6Number theoryPrefix sum+1No attempts yet2s512 MBJudgeable
OR Score of a SequenceSplit the array into K contiguous non-empty groups and maximize the sum of each group's bitwise OR.Medium6Dynamic programmingBit manipulation+1No attempts yet2s512 MBJudgeable
Sequence Sorting QueriesGiven a sequence, each query sorts it, adds X to the elements at positions L through R, and sorts again; output the final sorted sequence.Medium6SortingImplementation+2No attempts yet1s128 MBJudgeable
BracketsGiven a bracket string, decide whether flipping the brackets in at most one contiguous segment can turn the whole string into a balanced, valid bracket sequence.Medium6GreedyPrefix sum+2No attempts yet2s512 MBJudgeable
Go--Given a board with black and white stones, count the square sub-areas that contain stones of only one color and report the two totals.Medium6Prefix sumMatrix+1No attempts yet1s512 MBJudgeable
XOR Sum 3Compute the XOR of every contiguous subsequence of A and print the sum of all those XOR values.Medium6Bit manipulationPrefix sum+1No attempts yet2s512 MBJudgeable
Painting the fencePick a pairwise non-overlapping set of intervals to cover as many of the n slats as possible, then report the number left unpainted.Medium6SortingDynamic programming+2No attempts yet2s512 MBJudgeable
Eleven LoverFor each number given as a digit string, count its substrings with no leading zero that are divisible by 11.Medium6MathPrefix sum+1No attempts yet8s512 MBJudgeable
Area between a lattice path and its chordGiven a monotone path of up and right steps, compute the total area between the path and the straight chord from start to end.Medium6GeometryPrefix sum+2No attempts yet8s512 MBJudgeable
University RankingsGiven M rankings of N universities, find the longest sequence where each earlier university beats the next in every ranking.Medium6Dynamic programmingSorting+1No attempts yet8s512 MBJudgeable
Merging Files 2Given the sizes of K consecutive chapter files, find the minimum total cost of merging them two at a time into one file, where each merge costs the sum of the two sizes.Medium6Dynamic programmingPrefix sumNo attempts yet6s512 MBJudgeable
Mirko's averageAfter each pair of position updates, report whether Mirko's repeated pairwise average increased, decreased, or stayed the same.Medium6MathImplementation+1No attempts yet2s512 MBJudgeable