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,698 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Product Sum QueriesFor each query K, sum the products of all K-element subsets of A, counting positions separately, modulo 100003. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Daruma OtoshiGiven a stack of weighted blocks, remove adjacent pairs whose weights differ by at most 1, in any order, to maximize the total removed. | Medium6 | Dynamic programmingIntervals | No attempts yet | 2s | 512 MB | Judgeable |
| Big TruckFind a shortest path from node 1 to node n in an undirected weighted graph, and among all shortest paths maximize the total items collected at visited nodes. | Medium6 | GraphShortest path+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Nine PacksGiven multiset pile sizes of hotdog and bun packs, buy the fewest total packs so the chosen hotdogs and buns sum to the same number. | Medium6 | Dynamic programming | No attempts yet | 2s | 512 MB | Judgeable |
| A Typo in FloydCount ordered pairs whose shortest-path values differ when Floyd's outer loop skips vertex N as an intermediate. | Medium6 | Shortest pathDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Message PassingCount the telephone calls made at time t when each informed employee calls d new people over the next d time units, modulo 31991. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Bless You Autocorrect!For each target word, compute the fewest keystrokes using letter keys, tab (autocomplete to the most common dictionary word matching the typed prefix), and backspace. | Medium6 | TrieDynamic programming+1 | No attempts yet | 3s | 512 MB | Judgeable |
| Coin ExchangeGiven the generating-function coefficients of a coin multiset, answer queries that remove N coins of value V and report the new coefficient of x^D modulo 1e9+7. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Iterated SumsCompute S(k, n) mod 1,000,000,007, where S iterates prefix sums k times starting from S(0, n) = n. | Medium6 | CombinatoricsMath+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Painting the BoardGiven a grid picture of black and white squares, find the minimum number of horizontal or vertical strokes that paint exactly the required black squares. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| SW Skill TestPick and order problems within T minutes, each solved back to back, to maximize the sum of M_i - (start minute) * P_i. | Medium6 | Dynamic programmingSorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Safe RacingCount binary circular arrangements of L booths where every S consecutive booths contain at least one marshal, modulo 123456789. | Medium6 | CombinatoricsDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| JetpackFind the lexicographically smallest schedule of screen holds that moves Barry right across N columns through a 10-row grid while avoiding obstacles. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 64 MB | Judgeable |
| MacbethGiven n time intervals and w witches, each witch predicts a chain of non-overlapping intervals, so find the maximum number of intervals coverable by w chains. | Medium6 | IntervalsGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| CompilerPrint the specific 40-instruction-bounded program that displays N on a one-register display, following the stated decomposition rule. | Medium6 | Dynamic programmingMath+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Knight Moves to a CornerCount knight walk sequences of length at most k starting from a board corner and ending on any corner of a 2n x 2n board, modulo 1000007. | Medium6 | Dynamic programmingMatrix+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Unstacking BoxesBoxes sit in piles in a row; a box can be removed only when it is on top and at least one side is unblocked. Find the fewest removals needed to expose box 1. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Even Number of TollsFind the cheapest walk from city 1 to city C in a weighted undirected graph where the number of edges traversed (tolls paid) must be even, counting repeated edges each time. | Medium6 | GraphShortest path+2 | No attempts yet | 1s | 512 MB | Judgeable |
| TeleportationCount length-L button sequences that move from ship S to ship T, where each ship has four outgoing transitions, modulo 10^4. | Medium6 | MatrixDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Buses and MinibusesGiven a total line length N, count ordered sequences of 10-meter buses and 5-meter minibuses with K minibus colors and L bus colors, and print the last six digits. | Medium6 | CombinatoricsDynamic programming+1 | No attempts yet | 2s | 512 MB | Judgeable |
| CardsGiven an even row of cards with integers, two players alternately take an end card; the first player maximizes his total sum while the second minimizes it. Report the best score the first player can guarantee. | Medium6 | Dynamic programmingGame theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Alien Ribonucleic AcidFor each strand, compute the largest number of base pairs (B-S and C-F) that can form when disjoint intervals fold onto themselves. | Medium6 | Dynamic programmingIntervals | No attempts yet | 2s | 512 MB | Judgeable |
| Cash BookGiven N amounts and a signed total F, decide for each amount whether it is forced to be added, forced to be subtracted, or free, over all sign choices summing to F. | Medium6 | Dynamic programmingBacktracking+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Survival Probability of a Water FleaCount the paths of length n on a line starting at k that never return to 0, so the survivor count is S in S/2^n. | Medium6 | CombinatoricsDynamic programming+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Longest Common Subsequence of Two PermutationsTwo permutations of 1 to N are given; find the length of their longest common subsequence. | Medium6 | Dynamic programmingBinary search | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Medium6 | SortingDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Longest Zigzag SubsequenceFind the length of the longest subsequence whose adjacent comparisons strictly alternate between up and down. | Medium6 | Dynamic programmingGreedy | No attempts yet | 2s | 512 MB | Judgeable |
| BarbellsGiven up to 14 bars and 14 plates, find every total weight obtainable by putting plates on both sides of one bar so that the two sides balance. | Medium6 | Brute forceHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Banking IIGiven a PIN and a leftover lowercase pattern, insert uppercase skips so the letter values sum to the PIN length, maximizing the extracted digit sum. | Medium6 | Dynamic programmingGreedy | No attempts yet | 1s | 512 MB | Judgeable |
| Pokemon Identification SystemWith a budget B, buy k_f agents for each feature (k_f >= 1) to maximize the product of 1-(1-r_f)^k_f, and report the smallest optimal cost. | Medium6 | Dynamic programmingMath+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Step Step EvolutionGiven a sequence of dance-pad arrows, find the minimum number of adjacent pairs pressed by the same foot, respecting the left/right column rule. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 8s | 512 MB | Judgeable |
| Optimal RestGiven a sequence of R commands with dotted durations, find the shortest valid equivalent expression, breaking ties by lexicographic order. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 8s | 512 MB | Judgeable |
| So SleepyFind the longest total time asleep on one train while traveling from a start station and time to an appointment station by a deadline. | Medium6 | GraphShortest path+1 | No attempts yet | 8s | 512 MB | Judgeable |
| Lying about your ageTrack the smallest claimable value at a real age given a starting claim, where a claim read in some base equals the real age and claims never decrease. | Medium6 | Number theoryDynamic programming+1 | No attempts yet | 8s | 512 MB | Judgeable |
| University RankingsGiven M rankings of N universities, find the longest sequence where each earlier university beats the next in every ranking. | Medium6 | Dynamic programmingSorting+1 | No attempts yet | 8s | 512 MB | Judgeable |
| Building Uppercase SentencesCount the distinct uppercase sentences you can form by deleting letters and grouping the rest into blocks of three identical letters. | Medium6 | Dynamic programmingString | No attempts yet | 1s | 256 MB | Judgeable |
| Finding a HouseOn a weighted undirected graph, find the vertex with no McDonald's or Starbucks whose distance to the nearest McDonald's is at most x, to the nearest Starbucks at most y, and whose two distances sum to the minimum. | Medium6 | GraphShortest path+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Alien Creature NumberingCount the labelings of a complete binary tree of height H with 1..2^(H+1)-1 where every parent's label is smaller than its children's labels, modulo 1e9+7. | Medium6 | CombinatoricsTree+1 | No attempts yet | 1s | 256 MB | Judgeable |
| PohlepkoFind the lexicographically smallest string read along a monotone path from the top-left to the bottom-right cell of a grid of lowercase letters. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Emptying the GlassesGiven N glasses and pairwise pour costs, find the minimum effort to end with water in at most K glasses. | Medium6 | Dynamic programmingGraph+2 | No attempts yet | 2s | 32 MB | Judgeable |
| 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. | Medium6 | Dynamic programmingPrefix sum | No attempts yet | 6s | 512 MB | Judgeable |
| Small PhD RestaurantGiven N challenges with cost A_i and payoff B_i, starting money M, choose an order to maximize final money while affording each cost. | Medium6 | GreedySorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| The Longest Travel RouteGiven a directed weighted graph with at most 18 cities, find the maximum total length of a simple path from city 0 to city n-1. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Grayscale PhotoCount the color photos (RGB triples) whose floor average matches each given gray value, modulo 10007. | Medium6 | CombinatoricsMath+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Anadrome splitSplit a lowercase word into the fewest substrings that are each anagrams of some palindrome, breaking ties by the lexicographically smallest printed line. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Multiple SubsequenceGiven a sequence, find the longest subsequence where each element is a larger multiple of the previous one. | Medium6 | Dynamic programmingSorting | No attempts yet | 2.5s | 256 MB | Judgeable |
| Connecting switches to bulbsCount the number of functions from A numbered switches onto B numbered bulbs, modulo 1000000007, i.e. B! times Stirling number of the second kind S(A, B). | Medium6 | CombinatoricsDynamic programming+2 | No attempts yet | 1s | 64 MB | Judgeable |
| Cow ChecklistFind the cheapest path that visits all Holsteins in order and all Guernseys in order, starting at Holstein 1 and ending at Holstein H. | Medium6 | Dynamic programmingGeometry | No attempts yet | 2s | 512 MB | Judgeable |
| Electoral CollegeGiven each state's win probability and electoral votes, find the probability that Jenabkhan gets more than half of the total electoral votes. | Medium6 | Dynamic programmingProbability | No attempts yet | 2s | 512 MB | Judgeable |
| Halting MachineParse N goto statements, build a directed graph, and print the longest path length from line 0 to line N, or infinity if a cycle is reachable on some path to N. | Medium6 | GraphDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Key Rearrangement 2Given n keys with lists of compatible keyholes and a time limit k, decide whether a perfect matching exists with total |i-j| cost at most k. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Partitioning Balls into BucketsCount the ways to split N balls into buckets whose sizes are non-decreasing, span at most 2, and start with a value divisible by D. | Medium6 | Dynamic programmingMath+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Partitioning Number (Large)Count non-decreasing partitions of N whose first part is divisible by D and whose parts span a range of at most 2. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Monster Path (Small)Given a small grid, a start cell, and a fixed step count, choose a walk maximizing the expected number of distinct monsters caught. | Medium6 | Dynamic programmingBit manipulation+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Counting Distinct SubsequencesCount the distinct subsequences of a string, including the empty string, for up to 10,000 test cases. | Medium6 | Dynamic programmingString+1 | No attempts yet | 1s | 512 MB | Judgeable |
| WhitespaceGiven the line lengths of a Whitespace program and a RETURN key that duplicates the current line's spaces, find the minimum key presses to build the text from a single newline. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence PermutationsCount how many distinct permutations of 1..N are reachable from the sorted order by exactly M adjacent swaps, modulo 1,000,000,009. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Two OperationsStarting from X = Y = 1, repeatedly add one variable to the other, and find the shortest (then lexicographically smallest) operation string that makes N appear. | Medium6 | BFSGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hoof, Paper, Scissors (Gold)Given John's sequence of N gestures and at most K gesture switches, find the maximum number of games Bessie can win. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Why Did the Cow Cross the Road 7On an N x N grid, find the fastest route from the top-left to the bottom-right cell when every third move forces Bessie to spend that cell's eating time. | Medium6 | GraphShortest path+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Snake JOIFind the shortest travel time from room 1 to room N where entering a hot room requires X minutes since last leaving a cold room, and vice versa. | Medium6 | Shortest pathGraph+1 | No attempts yet | 2s | 512 MB | Judgeable |
| MemoryGiven R times C face-down cards forming pairs, find the best-case and worst-case number of actions a perfect-memory player needs to clear the board. | Medium6 | Game theoryMath+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Taekwondo KingWith S < T, using combo A doubles S but adds 3 to T, and combo B adds 1 to S. Find the fewest kicks that make S equal T. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Younghoon's Coloring BookCount the ways to place one red and one blue cell in each row and column of an N x N grid, with no cell both colors, modulo 1e9+7. | Medium6 | CombinatoricsMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Island TripGiven an undirected graph with node heights, for each query (A, K) find the minimum height reachable from A in exactly K edge steps, or -1 if impossible. | Medium6 | GraphDynamic programming+2 | No attempts yet | 1s | 256 MB | Judgeable |
| PosterizeChoose k allowed red values so the weighted sum of squared distances from the d distinct intensities is minimized. | Medium6 | Dynamic programmingMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sickly YunhoGiven a string of B, L, D doses, remove from either end in the fixed order B, L, D, B, L, D... and find the most doses removable before the required dose is missing from both ends. | Medium6 | Dynamic programmingArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| The County FairFarmer John visits booths with fixed giveaway times and directed travel times, choosing a route that collects the most prizes. | Medium6 | Dynamic programmingGraph+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Fashion ShowGiven a legal partial placement of +, x, and o models on an N by N grid, add or upgrade models to maximize style points under the row/column and diagonal rules. | Medium6 | GraphTwo pointers+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Fresh Chocolate (Small)Choose the order of groups so that as many as possible receive only chocolate from freshly opened packs, given that leftovers must be finished first. | Medium6 | GreedyMath+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Dumpling shop owner Seungwon ParkMake at most limited numbers of m filler dumplings and unlimited filler-free ones from n grams of flour to maximize sales. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| CatsFind the minimum number of moves to reorder a line of cats, dogs, and lions so no cat is adjacent to a dog. | Medium6 | GreedyDynamic programming+2 | No attempts yet | 1s | 16 MB | Judgeable |
| Playing with FireTwo distinct people start just above the burning top tile and each step down or diagonally, never landing on the same tile; count escape sequences. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Game MapGiven an undirected connected graph, find the longest simple path where the degree of each successive vertex strictly increases. | Medium6 | GraphDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Lemonade TradeGiven a sequence of one-way lemonade exchanges walked in order, find the maximum litres of blue obtainable starting from one litre of pink, capped at 10. | Medium6 | Dynamic programmingHash map+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Stationary bike programsCount sequences of T levels where each step changes by exactly 1 and all values stay between M and N, modulo 1e9+7. | Medium6 | Dynamic programming | No attempts yet | 1s | 1024 MB | Judgeable |
| HipercampoGiven two anchors on the x-axis and N points above, choose the largest subset whose segments to both anchors meet only at the anchors. | Medium6 | GeometrySorting+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Red RoverGiven a route string over N, S, E, W of length at most 100, find the minimum total length of a message using one optional macro M and its definition that expands to the route. | Medium6 | Dynamic programmingString | No attempts yet | 2s | 512 MB | Judgeable |
| A Question of IngestionGiven n hourly courses with calorie counts, maximize total calories eaten when the per-hour limit starts at m, shrinks to two thirds while eating, and resets after two skipped hours. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Ducks in a RowFind the fewest flips needed so the string contains at least k maximal runs of D of length at least n. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Jumping HaybalesOn an n by n grid with haybale obstacles, find the fewest jumps of length 1 to k moving only east or south from the top-left corner to the bottom-right corner, or -1 if unreachable. | Medium6 | BFSDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Dangerous DiscusGiven falling acid drops in columns, decide whether the single-pixel disc can stay at some height and cross without ever touching a drop. | Medium6 | Dynamic programmingSliding window+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Intuidiff IIGiven intervals in the order they appear in a modified document, choose a subsequence of intervals whose original ranges strictly increase; maximize total characters left plain. | Medium6 | Dynamic programmingIntervals+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Just Terraffic!Given sorted trigger times, count cars with two axles and cars with three axles where gaps under 1000 ms join the same vehicle and gaps over 2000 ms split them. | Medium6 | Dynamic programmingGreedy | No attempts yet | 3s | 512 MB | Judgeable |
| Asphalt PavingGiven segments on a triangular grid, choose the largest subset so that no two share an endpoint at an acute angle. | Medium6 | GraphDynamic programming+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Dice BettingCompute the probability that at least k distinct values appear when an s-sided die is rolled n times, and print it to nine decimals. | Medium6 | ProbabilityDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hay BalesGiven a string of C and P, each move sorts any three consecutive characters so all C come before all P; find the minimum number of moves to fully sort the whole row. | Medium6 | GreedyString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Global WarmingThe friendships form a disjoint union of cliques, so each connected component of even size must be split into a perfect matching of minimum total cost. | Medium6 | GraphDynamic programming+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Friend PalindromeGiven a friendship graph on up to 20 students, find the largest number of students that can form a palindrome-like line where every student except the possible middle one is paired with a friend. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Decisions, DecisionsGiven the truth table of an n-variable boolean function, count the vertices in its unique minimal binary decision diagram. | Medium6 | Dynamic programmingDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| PaversCount the tilings of a 2 x n board with 1x1 squares, 2x1 rectangles, and L-trominoes, and sum the total number of each paver over all tilings. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| A Strange TournamentGiven a sequence of distinct powers, choose a non-crossing knockout bracket minimizing the total absolute difference over all matches played. | Medium6 | Dynamic programmingDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Paasa NumbersFind the Nth positive integer whose digits never increase from left to right, given N up to 10^18 and 10^4 queries. | Medium6 | CombinatoricsDynamic programming+2 | No attempts yet | 3s | 512 MB | Judgeable |
| ExpressionFor each pair (x, y) print a postfix expression over x, +, -, *, / whose value is y, using the fixed construction the statement describes. | Medium6 | Dynamic programmingImplementation+1 | No attempts yet | 4s | 512 MB | Judgeable |
| Enumerating BracketsGiven N and M, print the M-th balanced bracket sequence of length N in lexicographic order, where '(' is smaller than ')'. | Medium6 | CombinatoricsDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Barn PaintingCount the proper 3-colorings of a tree consistent with some pre-colored nodes, modulo 1e9+7. | Medium6 | TreeDynamic programming+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Minimum editCompute the Levenshtein distance between two lowercase strings, using the fewest insert, delete, and replace operations to change A into B. | Medium6 | Dynamic programmingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Tap Titanz at Moloco (Easy)On an n by n black/white board, each tap flips a whole same-color connected region; find the minimum taps to make the board one color. | Medium6 | GraphBFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Farm VillageEach house along a road needs one crop unit and can grow up to two; minimize the total growing cost plus cost of carrying crops between neighbors. | Medium6 | Dynamic programmingGreedy | No attempts yet | 2s | 512 MB | Judgeable |
| The PricesChoose for each product a wholesaler to buy it from, paying each visited wholesaler's round-trip cost once, to minimize the total. | Medium6 | Dynamic programmingBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |