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 results3,688 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
HistogramsGiven histogram H and point set S, build a valid histogram from S points that minimizes diffcount or abserror against H.Hard8Dynamic programmingPrefix sumNo attempts yet1s256 MBJudgeable
Buffed BuffetFill a plate of weight exactly w from discrete pieces and divisible dishes with linearly fading tastiness to maximize total tastiness.Hard8Dynamic programmingBinary search+2No attempts yet4s128 MBJudgeable
Beads and WiresYou choose append and insert orders that build the given weighted tree to maximize the total length of insert-created edges.Hard8Dynamic programmingTree+2No attempts yet1s128 MBJudgeable
CardsThe program decides after each swap of two two-sided cards whether one face per card can show numbers that never decrease left to right.Hard8Segment treeDynamic programmingNo attempts yet3s256 MBJudgeable
RallyFind the vertex whose removal minimizes the longest directed path in a DAG and report that minimum length.Hard8Topological sortDynamic programming+1No attempts yet1s256 MBJudgeable
Tourist Information PointsChoose minimum-cost towns so every town holds a point or borders one.Hard8Dynamic programmingGraphNo attempts yet1s256 MBJudgeable
Persuading the AdvisersTwo rivals take turns claiming undecided experts for opposite sides, and the first asks whether he can force the majority-vote tree to favor him.Hard8Game theoryTree+2No attempts yet1s256 MBJudgeable
Doubling gameGiven a binary grid, compute for each cell the largest token pile reachable by repeatedly merging equal adjacent piles.Hard8Dynamic programmingBFS+1No attempts yet10s256 MBJudgeable
Test Data AnalysisCount bounded arrays of length N whose maximum contiguous subarray sum equals D, modulo 1,000,000,007.Hard8Dynamic programmingPrefix sum+1No attempts yet2s256 MBJudgeable
CheatsCount the completion orders of a tree of prerequisites when up to k parent edges can be skipped to grandparents, with no two skipped edges adjacent.Hard8Dynamic programmingTree+1No attempts yet10s256 MBJudgeable
Super Mario 169Choose the switch order and the coin pickup routes in 3D so Mario collects every coin with the least total swim distance.Hard8Dynamic programmingGeometry+1No attempts yet3s256 MBJudgeable
PawnsDecide whether White or Black wins a pawn race where each side moves only its own pawns forward until every column is blocked.Hard8Game theoryDynamic programmingNo attempts yet1s256 MBJudgeable
Sweet WarTwo players alternate passing at one energy each or eating the next ball for its nutrition and taste, and each maximizes total taste eaten.Hard8Game theoryDynamic programmingNo attempts yet1s256 MBJudgeable
Shrine MaintenanceSplit the shrines on a circle of radius 1000 among W workers leaving from the center so the longest round trip is as short as possible.Hard8Dynamic programmingGeometry+1No attempts yet2s256 MBJudgeable
Hari MerdekaChoose a string over priced letters with total cost within the budget to maximize the summed scores of all occurrences of the given words.Hard8Dynamic programmingString matchingNo attempts yet3s256 MBJudgeable
Galaxy collisionYou split the points into two groups whose internal distances exceed 5 and minimize the smaller group.Hard8GraphBFS+2No attempts yet3s256 MBJudgeable
Road RepairFind a tree path with total cost at most C that maximizes total benefit.Hard8TreeDivide and conquer+1No attempts yet1s256 MBJudgeable
How Does Your Garden Grow?Place up to 50 one-metre plants on a 10 cm grid so the squared gap between each plant water need and the sprinkler water its interval collects is minimal.Hard8Dynamic programmingMath+1No attempts yet30s256 MBJudgeable
Out of contextFor each text line, print the longest substring the given grammar generates, breaking ties by earliest position, or NONE.Hard8Dynamic programmingString matchingNo attempts yet10s256 MBJudgeable
ParadesPick the most parade routes between pairs of junctions in a tree so no street is shared by two parades.Hard8Dynamic programmingTree+1No attempts yet3s256 MBJudgeable
Virus synthesisBuild each DNA string over A, C, G, and T from empty using single-letter attachments or mirrored duplication in the fewest operations.Hard8Dynamic programmingString matchingNo attempts yet20s256 MBJudgeable
The ImpPick boxes in some order while an adversary voids up to k of them, and maximize the kept item value minus all purchase costs under optimal play.Hard8Game theoryDynamic programming+1No attempts yet15s256 MBJudgeable
Volunteer CampStarting from each house in a weighted tree, find the shortest truck route that visits K marked houses without driving back.Hard8TreeDynamic programming+1No attempts yet2s128 MBJudgeable
Transmutation CirclesFind the activation order of nested circles that maximizes total energy from element flips in already active circles.Hard8Dynamic programmingTree+1No attempts yet10s256 MBJudgeable
Integer GamePlayers alternately remove a number with no larger remaining neighbor from a row permutation, and whoever takes 1 wins, so decide the winner under optimal play.Hard8Game theoryDynamic programmingNo attempts yet5s256 MBJudgeable
Stamp StampFind the fewest inked cells in a stamp whose two unrotated presses produce the given paper.Hard8Dynamic programmingGraph+2No attempts yet10s256 MBJudgeable
ImprovementsReposition ships on a line from a station so no two ropes joining consecutive ships cross, keeping as many ships as possible in place.Hard8Dynamic programmingCombinatorics+1No attempts yet1s256 MBJudgeable
Integer in IntegerCount how many times C appears as a (possibly overlapping) substring in the decimal writings of all integers from A to B, modulo 1000000007.Hard8Dynamic programmingString matching+1No attempts yet10s128 MBJudgeable
Fallen Apples and the Nearest TreeFor each yearly apple drop on a grid, output the squared Euclidean distance to the nearest existing tree, counting the new tree only from the next year.Hard8GeometryDynamic programming+2No attempts yet2s128 MBJudgeable
Stack MazeYou move only right or down through the grid, pick up lettered jewels, and drop them into matching holes in last-in-first-out order for the most matches.Hard8Dynamic programmingStack+1No attempts yet8s256 MBJudgeable
Floating IslandsFind the cheapest connected bridge network where each bridge costs the position difference and each island has a degree limit, or report -1 when impossible.Hard8Dynamic programmingMinimum spanning tree+1No attempts yet8s512 MBJudgeable
The Light King and the Mirror Maze 2Count the ways to fill each ? with /, \ or empty on an N by M board so the beam entering border port x leaves at port y, modulo 10007.Hard8Dynamic programmingGraph+1No attempts yet2s256 MBJudgeable
Slave to Achievements 3Starting from M scraps, repeated crafting and dismantling ends with fewer than N scraps, and you must report each final remainder probability modulo 1e9+7.Hard8ProbabilityDynamic programming+2No attempts yet3s256 MBJudgeable
HackerChoose a start on a valued ring and spread to neighboring computers each turn to maximize hacked value against an optimal blocker.Hard8Game theoryDynamic programming+1No attempts yet1s256 MBJudgeable
Queen BeeEach day border cells grow by given amounts and each inner cell copies one of three neighbors by its rule table, and you report every cell size after N days.Hard8Dynamic programmingSimulation+1No attempts yet5s256 MBJudgeable
Bali SculpturesSplit N sculptures in order into between A and B consecutive groups to minimize the bitwise OR of the group age sums.Hard8Dynamic programmingGreedy+1No attempts yet1s64 MBJudgeable
Hexagon travelCount the orders of L left turns, R right turns and M moves that leave a hex-grid robot on a red, green, or blue tile, modulo 1,000,000,007.Hard8Dynamic programmingCombinatorics+2No attempts yet2s32 MBJudgeable
Actually visible pointsCount the nondecreasing integer chains ending at the given values with no other chain point on the segment from the origin, modulo 1000000007.Hard8Number theoryCombinatorics+1No attempts yet1s256 MBJudgeable
The last wizardTen counters start at 1 and grow through T random additive updates; output their expected product scaled by A to the T modulo 1000000007.Hard8ProbabilityCombinatorics+2No attempts yet1s256 MBJudgeable
Wouldn't it be better to just earn garnets?Find the second-fastest travel time from island 1 to island N over walks that may repeat bridges, and the largest garnet total among walks with that time.Hard8Shortest pathDynamic programmingNo attempts yet10s128 MBJudgeable
Reducing Network DiameterPay per unit of reduction on tree edge weights so the longest path between any two nodes is at most D at minimum total cost.Hard8GreedyTree+2No attempts yet2s256 MBJudgeable
Tree of PainDecide for each small pattern tree whether it embeds into the organization tree with matching labels and ancestry preserved both ways.Hard8TreeDynamic programming+2No attempts yet1s256 MBJudgeable
Absurdistan Roads IIN cities each build a road to one random other city; compute the probability that the N roads connect all cities.Hard8CombinatoricsProbability+2No attempts yet1s256 MBJudgeable
Shibuya CrossingGiven the list of crossing path pairs, find the size of the largest group of people whose paths all cross each other.Hard8GraphDynamic programming+1No attempts yet1s256 MBJudgeable
Extensive OrCount n-element subsets of numbers below the huge binary bound formed by repeating s k times whose xor is zero, modulo 1e9+7.Hard8Dynamic programmingCombinatorics+1No attempts yet3s256 MBJudgeable
Primal PartitionsSplit the array into k consecutive segments to maximize the smallest segment score, where each segment scores its largest common prime factor or zero.Hard8Binary searchDynamic programming+1No attempts yet2s256 MBJudgeable
Marble MadnessMove marbles between adjacent bins to maximize the total absolute difference of neighbor counts, and report that maximum plus the fewest moves achieving it.Hard8Dynamic programmingMath+1No attempts yet1s256 MBJudgeable
Just a QuizTeresa interrupts randomly drawn known questions at chosen words to maximize expected correct answers within t seconds.Hard8Dynamic programmingTrie+1No attempts yet1s256 MBJudgeable
Train of ThreesYou repeatedly merge adjacent matching pairs in an array of 1s, 2s and numbers of the form 3 times a power of two to form the largest tile possible.Hard8Dynamic programmingIntervalsNo attempts yet5s256 MBJudgeable
Splitting into PrimesStarting from N, repeatedly split every composite into a random divisor pair and report the expected number of rounds until all parts are prime.Hard8ProbabilityDynamic programming+2No attempts yet1s256 MBJudgeable
Feeding the HerringsCount ordered triples summing to N with each part at least L and no digit 3 in any part, modulo 12345647.Hard8Dynamic programmingCombinatorics+1No attempts yet5s256 MBJudgeable
Kingdom TripFind the shortest subsequence from the first to the last point so every skipped point lies within distance d of its shortcut segment.Hard8Dynamic programmingGeometryNo attempts yet2s256 MBJudgeable
Call a CabPartition the ordered points into the fewest rides where each ride meets one type's minimum total distance and heading range limit.Hard8Dynamic programmingSegment tree+2No attempts yet5s256 MBJudgeable
Colored painting salesEach client buys a_i colored or b_i black-and-white paintings, and after each update count the sales with at least C colored buyers modulo 10007.Hard8Dynamic programmingSegment tree+1No attempts yet4s32 MBJudgeable
Party joke setsCount distinct joke-type sets from root-connected guest groups with unique values where each subtree below a guest forms consecutive numbers.Hard8Dynamic programmingTree+1No attempts yet1s32 MBJudgeable
Just a bit sortedFor each query bound K, count length-N lists with values 1 to K where each value above 1 has its predecessor before its last occurrence.Hard8CombinatoricsDynamic programming+1No attempts yet3s256 MBJudgeable
Butterfly EffectDecide adaptively where to spend up to k double-die rolls across n chained chance events to maximize the chance the last event ends positive.Hard8Dynamic programmingProbabilityNo attempts yet5s256 MBJudgeable
OlympicsWith each successful or failed lift draining energy, guarantee a successful lift within d of an unknown strength from 25 to 225 kg and minimize d.Hard8Dynamic programmingMathNo attempts yet2s256 MBJudgeable
Wooden SignsCount the arrow stacks that match the given permutation, with each board screwed to the prior board so neighbors overlap, modulo 2147483647.Hard8Dynamic programmingCombinatoricsNo attempts yet1s256 MBJudgeable
Tree AllocationPartition the nodes into blocks of at most B to minimize the worst root-to-leaf block count, for every choice of root.Hard8Dynamic programmingTree+1No attempts yet10s64 MBJudgeable
Content DeliveryPick an item and destination for each of m deliveries on a weighted tree with path caching to maximize total size times travel distance.Hard8Dynamic programmingTree+1No attempts yet5s256 MBJudgeable
Queue of SoldiersCount distinct lineups of soldiers with given heights where exactly K soldiers have a strictly shorter soldier ahead of them.Hard8CombinatoricsDynamic programming+1No attempts yet5s256 MBJudgeable
Round wordsGiven two words of length up to 2000, pick a rotation or reversal of each to maximize the LCS length and print that maximum.Hard8Dynamic programmingStringNo attempts yet2s128 MBJudgeable
Guessing GameIdentify a hidden integer from 1 to n with adaptive subset questions where each NO costs a and each YES costs b while minimizing the worst-case total.Hard8Dynamic programmingBinary search+1No attempts yet1s256 MBJudgeable
Find the missing rankCount score assignments within given ranges where no person receives rank R under tied ranking.Hard8Dynamic programmingCombinatorics+1No attempts yet2s32 MBJudgeable
GuardsCount the subsets of at least two applicants with pairwise coprime favorite numbers, modulo 1,000,000,007.Hard8Dynamic programmingNumber theory+1No attempts yet2s32 MBJudgeable
ShoppingChoose a right-and-down path from (1,1) to (H,W) that minimizes the price of visited and neighboring shops when one neighbor shop can be skipped at each step.Hard8Dynamic programmingShortest pathNo attempts yet2s512 MBJudgeable
Balloon RecoveryDistribute a shared energy budget across height changes so every balloon riding layered winds reaches position zero as early as possible.Hard8Binary searchDynamic programmingNo attempts yet5s512 MBJudgeable
Albocede DNA (Large)Count subsequences of S that split into one or more blocks of the form a^i b^j c^i d^j with i and j at least 1, modulo 1000000007.Hard8Dynamic programmingCombinatoricsNo attempts yet5s512 MBJudgeable
Costly Binary Search (Large)Given the cost of comparing against each array position, find the smallest worst-case total cost of an adaptive binary search for the insertion point.Hard8Dynamic programmingDivide and conquer+1No attempts yet60s1536 MBJudgeable
Merlin QA (Large)Cast every spell once in the order that leaves the most valuable leftovers, since free storehouse stock covers only inputs the current stock cannot.Hard8Dynamic programmingGreedy+1No attempts yet5s512 MBJudgeable
Runaway QuailStarting at zero on a line, catch every quail that flees outward at a speed below yours in the smallest possible total time.Hard8Dynamic programmingMath+1No attempts yet5s512 MBJudgeable
Drum Decorator (Small)Count cylindrical grid fillings where each cell holding K has exactly K equal neighbours, up to rotation, modulo 1e9+7.Hard8CombinatoricsDynamic programming+1No attempts yet5s512 MBJudgeable
Googlander (Large)Count the distinct self-avoiding walks on an R by C grid that start at the bottom left facing up and at each step go straight or turn right.Hard8Dynamic programmingRecursion+1No attempts yet5s512 MBJudgeable
ARAM (Large)Decide when to spend reroll currency on random champions to maximize the long-run win rate over many games.Hard8Dynamic programmingProbability+2No attempts yet120s512 MBJudgeable
Willow (Large)Two players pick starts on a coin tree and alternately take city coins while each used road closes for both, and the first player maximizes the score gap.Hard8Game theoryTree+1No attempts yet120s512 MBJudgeable
Trie ShardingSplit the strings among N labeled non-empty servers to maximize the total trie node count and report the maximum and the count of optimal splits modulo 1e9+7.Hard8Dynamic programmingTrie+1No attempts yet5s512 MBJudgeable
Let Me Tell You a Story (Large)Count the orders in which ministers can be fired while a salary complaint remains possible until the survivors are non-increasing, modulo 10007.Hard8CombinatoricsDynamic programmingNo attempts yet30s512 MBJudgeable
Observation Wheel (Large)Compute the expected total fare collected as visitors starting at uniform random gondolas fill all free spots on a circular wheel.Hard8ProbabilityDynamic programming+1No attempts yet5s512 MBJudgeable
Upstairs and DownstairsKonstantin chooses and orders at least K activities from limited copies to minimize the chance Ilia wakes after falling asleep.Hard8ProbabilityDynamic programming+2No attempts yet5s512 MBJudgeable
Lost PasswordGiven k = 2 and a string S, find the length of the shortest string containing every l33tspeak variant of each length-1 and length-2 substring of S.Hard8GraphShortest path+1No attempts yet5s512 MBJudgeable
Commute War (Large)Choose connecting services to minimize expected travel time when departures leave hourly and each ride faces repeated random inspection delays.Hard8Shortest pathProbability+1No attempts yet5s512 MBJudgeable
Wildcard (Large)Given two filenames A and B, find the shortest star pattern that matches A but not B, breaking ties by fewer stars then lexicographic order.Hard8Dynamic programmingString matching+1No attempts yet5s512 MBJudgeable
Closet Room (Large)Place the maximum number of 2-cell closets, each needing an empty door tile, on a grid with pillars so every door tile stays connected to the entrance.Hard8Dynamic programmingGraph+1No attempts yet5s512 MBJudgeable
Runs (Large)Count distinct rearrangements of the letters of S whose number of maximal equal-character blocks equals that of S, modulo 1000003.Hard8CombinatoricsDynamic programmingNo attempts yet5s512 MBJudgeable
Google RoyalePick starting and doubling coin-flip bets to maximize the chance of growing A dollars into V dollars before going broke.Hard8Dynamic programmingProbability+1No attempts yet5s512 MBJudgeable
Extreme Escalator Pogo (Large)Pick a starting blue step and a sequence of jump heights that change by at most one each time to maximize the tallest jump before a red landing.Hard8GraphDynamic programming+1No attempts yet5s512 MBJudgeable
City TourFind the longest simple cycle in a graph grown from a triangle by joining each new vertex to both ends of an existing edge.Hard8Dynamic programmingGraphNo attempts yet5s512 MBJudgeable
Travel Plan (Large)Visit every planet on a line exactly once and return to Earth, maximizing total travel distance without exceeding the fuel limit.Hard8Dynamic programmingSorting+1No attempts yet5s512 MBJudgeable
Fence BoardsPick the fewest boards from N unlimited lengths to total exactly L for a fence up to 1e18 long, or report IMPOSSIBLE.Hard8Shortest pathDynamic programming+1No attempts yet20s512 MBJudgeable
Sums with Distinct Column DigitsCount unordered additions that sum to N in base B where digits in each column are pairwise distinct, modulo 1000000007.Hard8Dynamic programmingCombinatorics+1No attempts yet5s512 MBJudgeable
Counting Cryptarithm EquationsCount unordered base-B summand sets with distinct digits in each column that sum to N.Hard8Dynamic programmingCombinatorics+1No attempts yet60s512 MBJudgeable
BacteriaRectangular colonies on a grid evolve each second by a north-and-west neighbor rule, and the task asks when every cell becomes empty.Hard8Dynamic programmingMatrixNo attempts yet5s512 MBJudgeable
MarblesGiven 2n marbles of n colors in a row, find the minimum height of non-crossing paths pairing each color, or -1 if impossible.Hard8Dynamic programmingImplementation+1No attempts yet5s512 MBJudgeable
Interesting RangesCount subranges of [L, R] containing an even number of decimal palindromes, for L and R up to 10^100, modulo 1e9+7.Hard8MathCombinatorics+1No attempts yet45s512 MBJudgeable
Stock ChartsPartition n stock price sequences into the fewest groups so that within each group no two polylines cross or touch at any time point.Hard8Dynamic programmingGreedy+1No attempts yet5s512 MBJudgeable
The Year of Code Jam (Small)Assign each '?' day blue or white to maximize total blue-day value, where a blue day starts at 4 and loses 1 for each blue neighbor above, below, left, or right in a grid of N months by M days.Hard8Dynamic programmingGraph+2No attempts yet5s512 MBJudgeable
The Year of Code Jam (Large)On a grid of N months by M days, choose white or blue for each '?' cell to maximize total happiness, where each blue day scores 4 minus its blue neighbors.Hard8Dynamic programmingGraph+2No attempts yet5s512 MBJudgeable
Painting a Fence (Large)Pick the fewest offers from N interval-and-color proposals so every one of 10000 fence sections is covered using at most 3 distinct colors.Hard8IntervalsGreedy+2No attempts yet10s512 MBJudgeable
Bus Stops (Small)Count the ways K buses starting at the first K stops can cover all N stops and end at the last K, with gaps of at most P.Hard8Dynamic programmingBit manipulation+1No attempts yet5s512 MBJudgeable