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,682 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Maximum Subarray 2147483647Given a sequence of n integers, find the maximum possible sum of a contiguous subarray, choosing at least one element. | Medium4 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Range Digit SumSum the decimal digits of every integer from L to U, inclusive, where U can reach two billion. | Medium5 | MathDynamic programming+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Unknown SentencePartition a sentence into segments that are anagrams of given words, minimizing total letters moved from their original word positions. | Medium5 | Dynamic programmingString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| HotelGiven advertising costs and customer gains for up to 20 cities with unlimited repeats, find the minimum total cost to gain at least C new customers. | Medium5 | Dynamic programmingMath | No attempts yet | 2s | 128 MB | Judgeable |
| PrefixGiven up to 50 words, find the largest subset where no word is a prefix of another, using a trie and tree DP. | Medium5 | TrieDynamic programming+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Solving ProblemsGiven N interest values and a rule to move forward by 1 or 2 steps starting at problem 1, find the minimum number of problems solved before the range of solved values reaches at least V. | Medium5 | Dynamic programmingGraph+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Tangled Electric WiresGiven a matching between left and right poles, find the minimum number of wires to cut so no two remaining wires cross, which reduces to computing N minus the longest increasing subsequence. | Medium5 | Dynamic programmingBinary search+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Array ValueFind a path from top-left to bottom-right of an N by N grid, avoiding zero cells, that minimizes the trailing zeros in the product of visited values. | Medium5 | Dynamic programmingMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Substring Picking GamePlayers alternately subtract a value formed by a proper substring of the current number's digits, and you must find the smallest first move that forces a win, or -1 if none exists. | Medium5 | Game theoryDynamic programming+2 | No attempts yet | 2s | 256 MB | Judgeable |
| New Year PartyPick a maximum-score guest list from a company tree so no employee and their direct manager both attend, computed with and without the root. | Medium5 | Dynamic programmingTree+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Making the Best TeamChoose 15 players for white and 15 for black from a list of up to 1000 players to maximize the total ability sum. | Medium5 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Captain DasomGiven N cannonballs, find the minimum number of tetrahedral-number piles whose sizes sum exactly to N using unbounded coin-change style DP. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Summit Handshakes 2Given N seats around a round table, count the ways N representatives can pair up with non-crossing handshake segments, modulo 987654321. | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Number GameGiven a set of numbers including 1 and a limit K, find the first integer that cannot be formed using at most K chosen numbers, then decide the game winner by turn parity. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Making a PalindromeFind the minimum number of integers to insert into a sequence so it becomes a palindrome, using interval or LCS-based dynamic programming. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| TilingCount the number of ways to tile a 2×n rectangle using 2×1 and 2×2 tiles for multiple values of n up to 250. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Sorting the BookshelfFind the minimum number of single-book relocations needed to sort a permutation of N books into increasing order. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| HighwayGiven a directed graph with edge lengths and tolls, find the minimum length path from city 1 to city N whose total toll does not exceed a budget K. | Medium5 | Dynamic programmingGraph+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Word ExtensionGiven a dictionary and a starting 3-letter word, find the longest word reachable by repeatedly inserting one letter such that each intermediate word exists in the dictionary. | Medium5 | Dynamic programmingString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Coin DistributionGiven several coin denominations with counts, decide for three test cases whether the coins can be split into two subsets of equal total value. | Medium5 | Dynamic programmingArray | No attempts yet | 2s | 128 MB | Judgeable |
| CheersGiven N people around a circle each drinking a cola brand, find the maximum number of non-crossing pairs connecting people with the same brand. | Medium5 | Dynamic programmingIntervals | No attempts yet | 2s | 128 MB | Judgeable |
| Jump Jump ChampionshipGiven an array, find the longest strictly increasing subsequence and output its length plus the indices of one such subsequence. | Medium5 | Dynamic programmingBinary search+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Relay RaceGiven N runners in fixed order each running 1 to 3 consecutive days, find the day-count assignment summing to exactly D that maximizes total distance, or -1 if invalid. | Medium5 | Dynamic programming | No attempts yet | 2s | 128 MB | Judgeable |
| Traveling Salesperson TourFind the minimum cost Hamiltonian cycle in a directed graph with up to 16 cities using bitmask dynamic programming. | Medium5 | Dynamic programmingBit manipulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Bug on a TreeGiven a tree with fruit values on vertices, find the maximum sum path (simple path) and its smallest-numbered starting endpoint. | Medium5 | TreeDynamic programming+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Wine TastingPick numbers from a sequence maximizing sum while never selecting three consecutive elements. | Medium5 | Dynamic programming | No attempts yet | 2s | 128 MB | Judgeable |
| In-Flight Meal TripFind the maximum-score path from city 1 to city N using at most M cities, moving only to strictly increasing city numbers along available flights. | Medium5 | Dynamic programmingGraph | No attempts yet | 2s | 128 MB | Judgeable |
| Mountain BikeFind the minimum travel time from top-left to bottom-right of a grid where each move's duration depends on cumulative speed changes from height differences, solvable via Dijkstra with speed encoded as exponent sums. | Medium5 | Shortest pathGraph+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Letter BoardCount the number of paths on an N by M letter grid that spell a given word, moving 1 to K cells in one straight direction per step. | Medium5 | Dynamic programmingMatrix+1 | No attempts yet | 2s | 128 MB | Judgeable |
| String CopyFind the minimum number of substring-copy operations from S needed to reconstruct P using greedy/DP over matching positions. | Medium5 | Dynamic programmingString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Marbles in BoxesGiven two marble sequences and a pairwise score table, choose a sequence of pop/pop/pop-both operations to maximize total matched-pair score, using LCS-like DP with reconstruction. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Team FormationPartition an age-ordered score sequence into contiguous groups to maximize the sum of each group's max-minus-min score. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Sequence ReductionDecide if repeatedly merging adjacent elements as A[i]-A[i+1] can reduce the sequence to a single target value T. | Medium5 | Dynamic programmingRecursion | No attempts yet | 2s | 128 MB | Judgeable |
| Plum TreeGiven a sequence of falling trees over T seconds, find the max plums caught starting at tree 1 with at most W moves between trees. | Medium5 | Dynamic programming | No attempts yet | 2s | 128 MB | Judgeable |
| JumpFind the minimum number of jumps from stone 1 to stone N where jump lengths change by at most 1 each step and some stones are blocked. | Medium5 | Dynamic programmingBFS+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Theater SeatsCount permutations where each ticket holder sits in their own or adjacent seat, with VIP seats fixed and splitting the row into independent segments counted by a Fibonacci-like recurrence. | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Buying JewelsFor each of n rows pick a contiguous non-empty subarray maximizing summed total value, breaking ties by fewest jewels then lexicographically smallest index sequence. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Tree CuttingGiven a tree with n vertices, find the minimum number of edges to cut so some resulting piece has exactly m vertices, or report impossibility. | Medium5 | TreeDynamic programming+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Fax CompressionChoose a quantization of a sequence into 4 levels with run-length style bit encoding to minimize error plus weighted code length. | Medium5 | Dynamic programmingString+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Dance Pad Minimum EnergyGiven a sequence of dance pad moves, compute the minimum total energy to press each in order by choosing which of two feet to move each time. | Medium5 | Dynamic programmingSimulation | No attempts yet | 2s | 128 MB | Judgeable |
| Polygon PartitionsCount noncrossing dissections of a regular N-gon into all triangles or all quadrilaterals, modulo 1e9, using Catalan-like combinatorics. | Medium5 | CombinatoricsDynamic programming+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Number of PermutationsGiven a permutation's up-down pattern, count permutations of size n sharing the same pattern, modulo 1,000,000,000. | Medium5 | Dynamic programmingCombinatorics | No attempts yet | 2s | 128 MB | Judgeable |
| Sum of Powers of TwoCount the ways to write N as an unordered sum of powers of two, modulo one billion. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Brotherly Field DivisionChoose a non-decreasing staircase cut across N columns of an N x N grid to minimize the harvest difference between the two regions, and output one such cut. | Medium5 | Dynamic programmingBrute force+1 | No attempts yet | 1s | 256 MB | Judgeable |
| ParameciaSimulate a population where each individual matures, reproduces daily within an age window, dies at a fixed age, and count survivors on day N modulo 1000. | Medium5 | Dynamic programmingSimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Electric WiresGiven wires connecting positions on two poles, find the minimum removals so remaining wires never cross, equivalent to n minus the longest increasing subsequence. | Medium5 | Dynamic programmingBinary search+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Crossing the Stone BridgesCount ways to match a scroll string to positions across two parallel bridge strings, alternating bridges and strictly increasing positions. | Medium5 | Dynamic programmingString | No attempts yet | 1s | 128 MB | Judgeable |
| Corporate InvestmentAllocate exactly N integer units of money across M companies using given profit tables to maximize total profit, then output an allocation, a classic knapsack-style DP task. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Submarine IdentificationDecide whether a binary string can be split into pieces of '01' or '1' followed by at least two 0s and at least one 1, using pattern matching or DP. | Medium5 | Dynamic programmingString matching+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Glass BallsGiven B balls and M floors, compute the minimum number of drops needed to guarantee finding the critical breaking floor in the worst case. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Adjacent Bit Pair CountCount binary strings of length n whose number of adjacent 11-pairs equals a given k, for up to 1000 queries. | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| KnightSimulate a knight's moves on an N x N board for T steps (T up to a million), where each square can only be entered at time-multiples of its written value, and output all possible final squares. | Medium5 | BFSSimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Dongjun's GameGiven N level scores, find the minimum total decrease needed to make the sequence strictly increasing while all scores stay positive. | Medium5 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Pleasant WordCount ways to fill blanks in a word with uppercase letters so it avoids three consecutive vowels or consonants and contains at least one 'L'. | Medium5 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| DebugGiven a binary R by C grid, find the largest square submatrix (side at least 2) that is invariant under 180-degree rotation, or output -1. | Medium5 | Dynamic programmingMatrix+1 | No attempts yet | 5s | 128 MB | Judgeable |
| FootnotesGiven text lines and footnotes attached to specific lines, compute the minimum number of pages so that each page holds consecutive text lines plus their footnotes within a line limit K. | Medium5 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Foot TypingGiven two words and their interleaving, output the lexicographically smallest sequence of 1s and 2s marking which word produced each character. | Medium5 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ExchangeGiven daily buy and sell exchange rates between marks and dollars, compute the maximum marks obtainable after N days starting from 100 marks, output as a reduced fraction. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Friends Calling PlanGiven call minutes between up to 16 employees, pair them all up to minimize total billing cost using bitmask DP over perfect matchings. | Medium5 | Dynamic programmingBit manipulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Hop, HopCount, modulo 1000000, the number of ways to write n as a non-increasing sequence of jumps of length 1, 2, or 3, for n up to 1e9. | Medium5 | MathDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Ancient ManuscriptCount ways to fill '*' letters in a word so runs of vowels/consonants respect maximum length and maximum equal-letter-repeat limits, using DP over letter classes and previous letter identity. | Medium5 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Decoding Morse SequencesCount the number of ways to split a given Morse code string into a sequence of dictionary words, using dynamic programming with Morse-to-word conversion. | Medium5 | Dynamic programmingString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Sangkeun TowerFor each elevator, find the minimum floor above 0 reachable using exactly n button presses (up/down moves), never going below 0, then take the overall minimum across elevators. | Medium5 | Dynamic programmingBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Graph MatchingCount the number of matchings (independent edge sets) of the cycle graph C_n for each given n, likely requiring big-integer arithmetic via a Lucas-sequence style recurrence. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ComputersGiven a fixed replacement cost and arbitrary maintenance costs for owning a computer over any year range, find the minimum total cost to cover n years using dynamic programming. | Medium5 | Dynamic programmingArray | No attempts yet | 1s | 128 MB | Judgeable |
| Game, Set and MatchGiven the per-point win probability p, compute the probabilities of winning a tennis game, set, and match using the standard scoring rules. | Medium5 | Dynamic programmingProbability+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Minimal BackgammonSimulate turn by turn probability mass over board positions (with lose-a-turn and go-to-start squares, and bounce-back overshoot rule) to find probability of reaching the goal within T turns. | Medium5 | Dynamic programmingSimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Sum of Distinct PrimesCount subsets of k distinct primes summing to n, using dynamic programming over sieve-generated primes up to 1120. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Maximum SumGiven n boxes of numbered balls, pick at most one ball per box in order to form a non-decreasing sequence with maximum possible sum. | Medium5 | Dynamic programmingSorting | No attempts yet | 1s | 128 MB | Judgeable |
| Faulhaber's TriangleBuild Faulhaber's triangle row by row using the recurrence F(i,j)=i/j*F(i-1,j-1) plus the normalization that each row sums to 1, then answer queries for F(m,k) as reduced fractions. | Medium5 | Dynamic programmingMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| CounterattackTwo strikers advance in lockstep through n points, each step either dribbling or passing to the partner; find the cheapest route from a long pass at point 1 to a shot at point n. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Pro-Test VotingGiven a budget and precincts whose vote gain follows a concave spending curve, allocate dollars to maximize rounded total votes, breaking ties toward lower-numbered precincts. | Medium5 | Dynamic programmingGreedy | No attempts yet | 1s | 128 MB | Judgeable |
| Largest SquareGiven a 0/1 matrix, find the side length of the largest all-ones square submatrix. | Medium5 | Dynamic programmingMatrix | No attempts yet | 5s | 256 MB | Judgeable |
| SkylineCount permutations of 1..N with no increasing subsequence of length 3, modulo 1,000,000, for each N up to 1,000. | Medium5 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Ferry Loading VGiven distinct vehicle weights, split them between two lanes so the totals differ as little as possible. Output the minimum difference. | Medium5 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Scrolling SignGiven k-wide words, find the minimum total letters scrolled in so that each word appears in order, allowing overlap between consecutive words. | Medium5 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Catamaran BallastSplit the given rock weights between two hulls so the difference of the two sums is as small as possible. | Medium5 | Dynamic programmingBrute force | No attempts yet | 1s | 128 MB | Judgeable |
| Multiplication GameAlice and Bob multiply a running product by 2 to 9 in turn; find who forces the product to reach n first with optimal play. | Medium5 | Game theoryDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Tight WordsCount words of length n over digits 0..k where adjacent digits differ by at most 1, then print that count as a percentage rounded to five decimals. | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Splitting Teams FairlySplit N people into two teams differing in size by at most one so their total weight difference is minimized, then print both totals in increasing order. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Old Wine Into New BottlesGiven a wine volume and bottle sizes with min and max capacities, maximize the bottled amount and print the leftover in millilitres. | Medium5 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Ferry LoadingLoad the longest prefix of cars onto two lanes of bounded total length, choosing lanes to maximize cars loaded and break ties lexicographically. | Medium5 | Dynamic programmingGreedy | No attempts yet | 1s | 128 MB | Judgeable |
| Hippity HopscotchOn an n by n grid of penny stacks, starting at (0,0) and jumping up to k cells in a row or column to a strictly larger stack, find the maximum total collected. | Medium5 | Dynamic programmingSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| PlinkoGiven rigged Plinko boards with per-peg right-move probabilities, compute for each start and end column the number of distinct paths and the truncated percentage chance. | Medium5 | Dynamic programmingProbability+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RIPOFFA token moves 1 to S squares per turn and must exit a board of N labeled squares within T turns; maximize the total of the squares landed on. | Medium5 | Dynamic programmingSliding window | No attempts yet | 1s | 128 MB | Judgeable |
| Signal StrengthFind the maximum signal strength reaching switch N-1 from switch 0 through a switch network with gain or loss multipliers on nodes and edges. | Medium5 | GraphDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RailroadGiven two sequences, decide whether a target sequence can be formed by repeatedly taking the front car of either train; once one train empties, the rest follow in order. | Medium5 | Dynamic programmingTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| PERMSFor each query (n, k), count permutations of 1..n having exactly k inversions, with n up to 18 and k up to 200. | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sequence WalkingGiven two ascending integer sequences, find the maximum sum of a forward walk that may switch sequences at shared values. | Medium5 | Dynamic programmingTwo pointers | No attempts yet | 1s | 128 MB | Judgeable |
| Robots on a GridCount monotone right/down paths from the top-left to the bottom-right of an n by n grid with blocked cells, modulo 2^31-1, and report whether the goal is reachable at all, or reachable only with up and left moves allowed. | Medium5 | Dynamic programmingDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| lsGiven a wildcard pattern where * matches any run of characters, print the input file names that match it, keeping input order. | Medium5 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Rig PlacementGiven n oil fields, a per-field investment cap m, and a total budget B, pick an investment amount for each field so total oil is maximized. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Study DaysDistribute H study hours among n courses, each with 10 grade thresholds, to maximize the average grade point, rounded to two decimals. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Yes or No?Pick between l and r questions to answer Yes, maximizing the sum of per-question expected correct probabilities, and report the maximum expectation to two decimals. | Medium5 | Dynamic programmingSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Biomedical EngineeringGiven a target string and a set of reusable component strings, find the minimum number of components whose concatenation equals the target, or report that it is impossible. | Medium5 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GerrymanderingSplit n precincts, each with P and Q vote counts, into two nonempty districts; find how many districts P can win (0, 1, or 2). | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SoccerCompute probability distribution of final scores after up to T seconds of a stochastic soccer simulation with passing, stealing, shooting, and absorbing states. | Medium5 | ProbabilityDynamic programming+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Battleground PreservationGiven past battle results with costs, find the cheapest chain of victories between two fighters and decide the winner, or output FIGHT! if neither dominates. | Medium5 | GraphShortest path+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Life ConnectionsGiven an undirected friendship graph, count the distinct shortest paths between each queried pair of nodes, where path length counts nodes. | Medium5 | GraphBFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| MessageGiven error and succession probabilities for a Martian alphabet, find the most likely original word for each intercepted message using maximum likelihood. | Medium5 | Dynamic programmingProbability | No attempts yet | 1s | 128 MB | Judgeable |