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,705 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Greeting Card EnvelopesPartition up to 15 card types into at most k groups so the total waste, where each group's waste uses one enclosing envelope sized to the group's max width and max height, is minimized. | Medium7 | Dynamic programmingBit manipulation+2 | No attempts yet | 3s | 512 MB | Judgeable |
| FunfairPick and order k games from n so the expected final money is maximized, then report that value. | Medium7 | Dynamic programmingSorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| CafebazaarAssign each full-time developer and each critical application to a matching partner while maximizing total payoff, or report -1 if impossible. | Medium7 | GraphDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Delete FilesGiven a top-aligned list of name boxes with widths, find the minimum number of axis-aligned rectangle selections whose deletions remove all 'y' files and keep all 'n' files. | Medium7 | Dynamic programmingGeometry+2 | No attempts yet | 5s | 512 MB | Judgeable |
| SpeedrunGiven per-road win probabilities, choose checkpoints to save at so the expected time to reach checkpoint n is minimized. | Medium7 | ProbabilityDynamic programming | No attempts yet | 8s | 512 MB | Judgeable |
| Cookie CounterCount sequences of D days, each amount in [0, X), summing to N, modulo 1e9+7. | Medium7 | CombinatoricsDynamic programming+1 | No attempts yet | 8s | 512 MB | Judgeable |
| Rock Paper Scissors RankingGiven each contestant's probabilities for scissors, rock, and paper, find the probability that contestant 1 finishes in place K of the recursive elimination tournament. | Medium7 | ProbabilityDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Greedy Coin ExchangeGiven sorted coin denominations starting with 1, decide whether the greedy largest-coin-first method always uses the fewest coins for every amount. | Medium7 | GreedyDynamic programming+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Knapsack in a Globalized WorldWith unlimited copies of n item sizes, decide whether some multiset sums to exactly k, where k can reach 10^18. | Medium7 | Number theoryDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| RoutingFind the minimum total processing time for a message from server 1 to server n, where each server blocks forwarding certain (previous server, next server) pairs and revisiting servers adds their cost again. | Medium7 | GraphShortest path+2 | No attempts yet | 2s | 512 MB | Judgeable |
| AbilityCompute the expected damage of one attack where abilities are tried in a uniformly random order without replacement until one fires, and output the fraction modulo 1e9+7. | Medium7 | ProbabilityMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| BitsGiven N bits and K odd random index toggles per operation after sorting, compute for each starting zero count the expected number of operations to reach all ones. | Medium7 | ProbabilityDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| CardsFind the probability that L random packs of N equally likely card types meet every demand D_i, output as a fraction mod 1e9+7. | Medium7 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| KangarooCount the alternating-direction routes by which a kangaroo visits every cell of a row exactly once, starting at cs and ending at cf. | Medium7 | Dynamic programmingCombinatorics | No attempts yet | 2s | 512 MB | Judgeable |
| Reading the stone slabAfter each range replacement on a string, count the number of subsequences equal to a given name of length at most 5, modulo 1e9+7. | Medium7 | Dynamic programmingSegment tree+1 | No attempts yet | 4s | 256 MB | Judgeable |
| Lottery interestCompute Kangho's expected balance after C weekly lottery drawings, where each ticket (one per won) is equally likely to win J, and print the exact fraction. | Medium7 | ProbabilityMath+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Birthday CakeCount proper colorings of a cycle with N vertices and K colors, plus a center, as vertices are forced to differ from the center over time. | Medium7 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Arcade!Given a triangular grid of holes with per-hole bounce probabilities and payouts, compute the expected payout of one dropped ball. | Medium7 | ProbabilityDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Gas StationsIn a connected undirected weighted graph, buy fuel at cities with given prices to travel from city 1 to city N at minimum total cost, with no tank limit. | Medium7 | GraphShortest path+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Card Hand SortingGiven a hand of up to 52 distinct cards, find the minimum number of remove-and-reinsert moves needed so each suit forms a block with ranks sorted ascending or descending. | Medium7 | SortingBrute force+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Jumping WormFind the shortest time for a worm to travel from the base of tree 1 to the top of tree N, where each climb, jump, and gravity rest costs one second, with a free move when standing on a tree top. | Medium7 | GraphShortest path+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Meeting at the Agreed MinuteCount pairs of walks of length T from nodes 1 and N that meet only at minute T, modulo 9973. | Medium7 | MatrixDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| JumpTiles on a grid give energy when visited; jump only right or up at cost B, and maximize the energy left on reaching tile N. | Medium7 | Dynamic programmingGraph+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Pry Sequence TransformationFind the minimum edit distance between strings A and B under weighted insert, delete, and replace costs, or print TOSS if it exceeds budget K. | Medium7 | Dynamic programmingString | No attempts yet | 2s | 512 MB | Judgeable |
| Algorithm study membershipChoose two algorithm types for each of N members in a mentor tree so every team (a node plus its children) can assign distinct types to its members, minimizing total teaching cost. | Medium7 | Dynamic programmingTree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Partition into segments 2Split the array into at most M contiguous segments, minimizing the maximum difference between the largest and smallest value within any one segment. | Medium7 | Binary searchDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Stair Climbing WorkoutCount length-N balanced U/D walk strings (never going below 0, ending at 0) that contain a given piece as a contiguous substring. | Medium7 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Factorials and a recurrenceGiven N and K, compute the number of divisors of S(N,K), where S follows the given recurrence, modulo 1,000,000,009. | Medium7 | Number theoryDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Metal Is LifeCount permutations of N distinct strings that satisfy up to 8 prefix constraints between fixed positions, modulo 1e9+7. | Medium7 | CombinatoricsBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Stephen CookTwo players alternately assign truth values to variables of a boolean formula; Cook moves first and wins if the formula ends true. Decide the winner under optimal play. | Medium7 | Game theoryDynamic programming+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Bridge AutomationGiven sorted boat arrival times, schedule bridge raises and lowers so no boat waits over 1800 seconds while minimizing total road closure time. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| The Witch's PuzzleGiven N words, permute the letters of each word independently and find the minimum number of nodes in the prefix tree (trie) of the resulting set. | Medium7 | TrieDynamic programming+2 | No attempts yet | 2s | 64 MB | Judgeable |
| GondolasPlace G gondolas at integer offsets on a loop of period 2T to minimize the total wait of N skiers, where each skier boards the first departure at or after their arrival. | Medium7 | Dynamic programmingSorting+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Buying FlowersCount integer sequences x_i with 0 <= x_i <= f_i summing to S, where N <= 20 and S up to 1e14. | Medium7 | CombinatoricsDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Birthday PartyCount ordered tuples of f positive integers summing to n whose greatest common divisor is 1, modulo 1e9+7, for up to 100000 queries. | Medium7 | Dynamic programmingNumber theory+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Increasing subsequences of length KCount length-K index subsequences whose values are strictly increasing, modulo 5,000,000. | Medium7 | Dynamic programmingSegment tree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Distinct Increasing Subsequences of Length KCount the distinct value sequences of length K that appear as increasing subsequences of the given array, modulo 5000000. | Medium7 | Dynamic programmingSorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Merging treesGiven a left-handed and a right-handed ternary tree, find the minimum number of vertices in a ternary tree that is a superposition of both. | Medium7 | TreeDynamic programming+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Curious GuardiansCount labeled trees on N cities where every vertex has degree at most K. | Medium7 | CombinatoricsDynamic programming+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Palindromic SubsequenceGiven a string and marked positions, find a palindromic subsequence covering the most marked positions, and report the length of the longest such one. | Medium7 | Dynamic programmingString | No attempts yet | 1s | 512 MB | Judgeable |
| Convex polygon quadrangulationSplit a convex 2N-gon into N-1 quadrilaterals with diagonal cuts and find the minimum total cut length. | Medium7 | Dynamic programmingGeometry | No attempts yet | 2s | 512 MB | Judgeable |
| Folding MachineGiven two integer tapes, decide whether folding one tape can ever produce the other. | Medium7 | Divide and conquerRecursion+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Space ElevatorFind the number on the N-th floor when floor numbers skip any containing the digit 4 or the substring 13, for N up to 10^18. | Medium7 | Binary searchMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| SMS ChampionshipGiven a keypad where letters need repeated presses and # separates same-key letters, find the minimum typing time with two alternating thumbs. | Medium7 | Dynamic programming | No attempts yet | 2s | 512 MB | Judgeable |
| Random Sort 2Compute the expected number of random swaps the process needs to turn a given permutation of size up to 10 into increasing order. | Medium7 | ProbabilityDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Buggy RobotGiven a grid and an existing command string, insert or delete single commands at minimum cost so the robot reaches the exit. | Medium7 | Dynamic programmingBFS+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Water Supply UpgradesAfter each of k permanent capacity increases on edges of a small graph, report the maximum flow between station 1 and station 2. | Medium7 | GraphDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Perfect SetsCount the subsets of {0,...,k} closed under bitwise XOR, where k can be as large as 10^9, modulo 10^9+7. | Medium7 | Bit manipulationCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Distinct AND values of subsequencesCount how many distinct values can appear as the bitwise AND of some subsequence of a given array, including the empty subsequence whose AND is 0. | Medium7 | Bit manipulationDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| String HashingCount valid strings of any length over ASCII 32 to 126 whose base-31 polynomial hash equals a given string's hash, modulo 1e9+7. | Medium7 | Dynamic programmingCombinatorics | No attempts yet | 2s | 512 MB | Judgeable |
| ButterflyChoose non-overlapping dates; each person pays only if all their dates are kept, so maximize total satisfaction. | Medium7 | IntervalsDynamic programming+2 | No attempts yet | 8s | 512 MB | Judgeable |
| Dungeon Quest IIGiven a fixed walking route through a grid of traps and up to 12 one-use potions, decide whether the agent can survive to the end. | Medium7 | Dynamic programmingBit manipulation+1 | No attempts yet | 8s | 512 MB | Judgeable |
| Merry ChristmasGiven a town road network and timed delivery requests, find the minimum number of Santas so every present arrives exactly at its scheduled time. | Medium7 | Shortest pathDynamic programming+1 | No attempts yet | 8s | 512 MB | Judgeable |
| Alice in FoxlandGiven two strings X and Y, find the longest common subsequence of X and Y that contains a required substring C as a contiguous block, or report impossible; among ties pick the lexicographically smallest. | Medium7 | Dynamic programmingString+2 | No attempts yet | 8s | 512 MB | Judgeable |
| The divisor conquersPlace the N cards one at a time so each new card divides the sum of the cards already down, and print the lexicographically smallest winning order or No. | Medium7 | BacktrackingGreedy+2 | No attempts yet | 8s | 512 MB | Judgeable |
| Sum of CubesWrite N as a sum of as few positive cubes as possible, and among the shortest sums output the one that is lexicographically largest. | Medium7 | Dynamic programmingBrute force+2 | No attempts yet | 0.5s | 256 MB | Judgeable |
| Hotel RewardsGiven nightly hotel prices and a K-points-per-free-night reward rule, find the minimum total cost of the whole trip. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Permutation Descent CountsCount permutations of order N with exactly v descents, modulo 1001113, for up to 1000 queries with N at most 100. | Medium7 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| AverageCount, over all N-tuples of integer marks from 0 to fullmarks, the total number of teachers whose mark equals the tuple's mean, modulo 1000000007. | Medium7 | CombinatoricsDynamic programming+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Tree StandsCount the K-vertex subsets of a tree in which every chosen vertex is adjacent to at least one other chosen vertex, modulo 1000000007. | Medium7 | TreeDynamic programming+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Quality ExpressionsGiven a bracket expression with ? placeholders and per-arity limits, choose values so the expression is valid and its value is as large as possible. | Medium7 | Dynamic programmingTree+1 | No attempts yet | 1s | 64 MB | Judgeable |
| Dinner BetGiven N balls, D drawn per round, and two size-C cards, find the expected number of rounds until one player completes their card. | Medium7 | ProbabilityDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Pascal's Hyper-PyramidsCompute the distinct multinomial coefficients on the base layer of a D-dimensional Pascal hyper-pyramid of height H, printed in ascending order. | Medium7 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Tiling a 3 by N WallCount the tilings of a 3 by N wall with dominoes, modulo 1e9+7, where N can be as large as 10^18. | Medium7 | Dynamic programmingMatrix+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Maximum IslandsGiven an n by m grid of land, water, and cloud cells where clouds may be either, maximize the number of 4-connected land components. | Medium7 | GraphDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Foreign PostcardsPlace postcards in random batches, flipping a batch when its top card is upside down, and compute the expected number left picture down. | Medium7 | ProbabilityDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Longest Increasing Subsequence 4Find a longest strictly increasing subsequence of A, and among all of maximum length output the lexicographically smallest one along with its length. | Medium7 | Dynamic programmingBinary search+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Restoring the longest increasing subsequenceFind the length of the longest strictly increasing subsequence of A and print the lexicographically smallest subsequence achieving that length. | Medium7 | Dynamic programmingBinary search+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Combining RiceballsGiven a row of riceballs, merge equal adjacent pairs or equal pairs with one ball between them, and find the largest size reachable. | Medium7 | Dynamic programmingIntervals+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Cheap TravelingFind a route from village 1 to N whose total fare is at most S and whose total travel time is smallest; rides and villages may repeat. | Medium7 | Shortest pathGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ProbabilityGiven probabilities of letters A to D, find the probability that an optimally played game fills a row of n cells in alphabetical order. | Medium7 | Dynamic programmingProbability+2 | No attempts yet | 1.5s | 512 MB | Judgeable |
| PyramidBuild an n-row triangular pyramid from a linear recurrence, then answer queries for the maximum value inside a downward triangular sub-pyramid. | Medium7 | Dynamic programmingArray+1 | No attempts yet | 4s | 512 MB | Judgeable |
| FormulaFind the maximum number of edges in a closed trail that uses every important edge at least once, or report that none exists. | Medium7 | GraphBit manipulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Equal Digit ProductsCount N-digit numbers whose digits in odd positions have the same product as the digits in even positions. | Medium7 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Two BallsTwo balls move on a grid for T seconds with different random rules; compute the probability they collide, to 4 decimals. | Medium7 | ProbabilityDynamic programming+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Adjacent Product GameChoose a subsequence of the given numbers to maximize the sum of products of adjacent chosen pairs. | Medium7 | Dynamic programmingGreedy | No attempts yet | 1s | 64 MB | Judgeable |
| Cake deliveryGiven a directed graph where every village must be reachable from village 1, find the minimum number of walks starting at village 1 that together cover all vertices. | Medium7 | GraphDynamic programming+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Team BuildingCount pairs of K-cow teams, one from each farmer, such that after sorting both teams John's cow beats Paul's in every paired rank, modulo 1000000009. | Medium7 | SortingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Arranging HeapsDivide N ordered mining points into K groups, each group merging into one heap at its last point, minimizing total weighted distance moved. | Medium7 | Dynamic programmingDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Christmas EveGiven n weighted warehouses on a line, choose k of them as teleporter sites so that moving every other warehouse's presents into a chosen site gives the least total weighted distance. | Medium7 | Dynamic programmingSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sunday CodingCount the distinct sequences of room-winner ranks obtainable when R rooms each hold S contestants with all ranks distinct. | Medium7 | CombinatoricsDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Task ProcessingEach task has a day window and a list of durations by start day; pick a subset and an order to finish as many tasks in their windows as possible. | Medium7 | Dynamic programmingBit manipulation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| ProficiencyGiven two counters with geometric service times, find the probability that all L1 people finish before all L2 people do. | Medium7 | ProbabilityDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| WolvesCount subsets of N sections, each holding at most one wolf, such that every given interval contains at least one chosen section, modulo 1e9+7. | Medium7 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Coloring a RectangleCount colorings of an N x M grid where every colored cell has an even number of colored side-neighbors. | Medium7 | Dynamic programmingBit manipulation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Convex SequenceSubtract 1 from elements of a sequence (N up to 50) so that it becomes convex, minimizing total subtractions. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Grade ConsolidationPlace all classes of each grade in classrooms so adjacent grades can share only after dropping conflicting class pairs, maximizing kept classes. | Medium7 | Dynamic programmingGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Main Campus Walk 3Count walks of exactly D minutes from building 1 back to itself in an undirected graph, with no restriction on repeated edges or vertices. | Medium7 | GraphMatrix+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sorting Array (Small)Split a permutation into K contiguous blocks, sort each block, then reorder at most P=2 blocks by swapping to fully sort the array; find the largest feasible K. | Medium7 | ArraySorting+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Codejamon Cipher (Large)Count how many sentences built from vocabulary words, each word internally shuffled, concatenate to each given enciphered string. | Medium7 | Dynamic programmingString+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Sherlock and Permutation Sorting (Small)For every permutation of 1..N, find the maximum number of order-preserving chunks with all earlier-chunk values smaller than later ones, then sum f(p)^2 modulo M. | Medium7 | Dynamic programmingCombinatorics+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Clash Royale (Small)Spend up to M coins upgrading N cards, then pick 8 cards to maximize the deck's total attack power. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Interleaved Output: Part 2Given a string that four computers can interleave into, find the largest number of times the IO computer could have printed its name. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 20s | 1024 MB | Judgeable |
| Family Hotel (Large)Rooms fill by repeatedly picking a random adjacent free pair until none remain; find the probability that a given room ends up occupied, modulo 1e9+7. | Medium7 | ProbabilityMath+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Forest University (Small)Count the fraction of topological orderings of a tiny rooted forest whose label string contains each given cool word as a substring, printed as an irreducible fraction. | Medium7 | Dynamic programmingTopological sort+2 | No attempts yet | 100s | 512 MB | Judgeable |
| Red Tape Committee (Large)Choose exactly K of N members, each with a known Yes probability, to maximize the chance that exactly half vote Yes. | Medium7 | Dynamic programmingProbability+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Close Match (Large)Fill question marks in two equal-length digit strings to make the scores as close as possible, breaking ties by the smallest C then smallest J. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Technobabble (Large)Given a list of two-word topics, find the maximum number of topics that could have been faked by combining the first word of one existing topic with the second word of another. | Medium7 | GraphDynamic programming+2 | No attempts yet | 5s | 512 MB | Judgeable |
| BFFs (Large)Each kid points to one BFF; find the largest circular seating where everyone sits next to their BFF. | Medium7 | GraphDFS+2 | No attempts yet | 5s | 512 MB | Judgeable |
| 4 BlocksFill the empty cells of a small N x M board with 1x1 and 2x2 blocks to maximize total score, given fixed 1x1 blocks. | Medium7 | Dynamic programmingBit manipulation+1 | No attempts yet | 2s | 512 MB | Judgeable |