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
TitleLevelTopicsSolvedTime limitMemory limitJudge
IndomieEach of the N people ahead takes a uniformly random remaining item among rice, sugar, and Indomie (Indomie limited to S). Find the probability Indomie remains for Felix, as a percentage.Medium4ProbabilityCombinatorics+2No attempts yet1s128 MBJudgeable
Longest Ordered SubsequenceGiven a sequence of N integers, find the length of the longest non-decreasing subsequence.Medium4Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
HandshakesCount the matchings of a path with n vertices, then print the last digit of that count.Medium4Dynamic programmingCombinatorics+1No attempts yet1s256 MBJudgeable
LadderCount the ways to climb s rungs with steps of one or two and report each answer modulo 2^p for up to a million queries.Medium4Dynamic programmingMathNo attempts yet1s128 MBJudgeable
MatchesStarting from one match, fire spreads to each neighbor no taller than the burning match, and the task asks for the largest group that can burn.Medium4Dynamic programmingArrayNo attempts yet1s128 MBJudgeable
MerchantFind the simple path, possibly empty, in a weighted tree whose edge weights sum to the largest value.Medium4TreeDynamic programming+1No attempts yet1s128 MBJudgeable
Missile ProtectorSelect the most missiles that form a non-decreasing height sequence in arrival order.Medium4Dynamic programmingBinary searchNo attempts yet1s128 MBJudgeable
CoinsCount the unordered combinations of up to 20 coin values that sum to the target amount M.Medium4Dynamic programmingCombinatoricsNo attempts yet1s128 MBJudgeable
The Frobenius ProblemCount the integers up to 1,000,000 that are not nonnegative combinations of four given numbers and report the largest such integer.Medium4Dynamic programmingNumber theoryNo attempts yet1s128 MBJudgeable
Job Scheduling by Open BiddingPick bids whose total seconds fit the available time so the total payment is as large as possible.Medium4Dynamic programmingNo attempts yet1s128 MBJudgeable
Mixing WordsDecide whether the third word interleaves the first two words while keeping each word's letter order.Medium4Dynamic programmingStringNo attempts yet1s256 MBJudgeable
Longest Common SubsequenceCompute the length of the longest subsequence shared by two uppercase strings of length up to 1000.Medium4Dynamic programmingNo attempts yet0.1s256 MBJudgeable
Privacy LossPick a subset of options that maximizes total security benefit without exceeding the money budget and the privacy limit.Medium4Dynamic programmingNo attempts yet1s128 MBJudgeable
StickersPick stickers from a 2 by n grid with no two sharing an edge to maximize the total score.Medium4Dynamic programmingArrayNo attempts yet1s256 MBJudgeable
Tree ColoringCount colorings of an N-node tree with K colors so adjacent nodes differ, modulo 93563.Medium4Dynamic programmingTree+1No attempts yet1s128 MBJudgeable
Diamond Mining ProfitsFind the contiguous period with the largest total gain across up to 2000 test cases, breaking ties by shorter length then earlier start.Medium4Dynamic programmingArray+1No attempts yet1s128 MBJudgeable
Sums of Distinct Natural NumbersCount the partitions of each given N into distinct positive integers, including N itself, modulo 100999.Medium4Dynamic programmingCombinatoricsNo attempts yet7s128 MBJudgeable
Joint VentureAssign each of the M modules to company A or B so total days stay within D and both budgets hold while total cost is minimized.Medium4Dynamic programmingNo attempts yet1s128 MBJudgeable
Magic Multiplying MachineChoose any subset of the given levers, including none, to maximize the product of chosen numbers modulo M.Medium4Dynamic programmingMathNo attempts yet2s64 MBJudgeable
WalkingWalkers start at distinct times with fixed speeds, and a later starter who arrives earlier befriends the other; find the largest group where every pair meets.Medium4Dynamic programmingSortingNo attempts yet1s128 MBJudgeable
HousingCount the unordered splits of n into parts of at least 5 for n between 5 and 100.Medium4Dynamic programmingCombinatoricsNo attempts yet2s512 MBJudgeable
PathsFind the cheapest total cost among the directed paths from node 0 to node 1 that use the fewest links.Medium4BFSDynamic programmingNo attempts yet2s512 MBJudgeable
CoinFind the fewest coins from unlimited denominations whose values sum to V and weights sum to W.Medium4Dynamic programmingNo attempts yet2s1024 MBJudgeable
Digit SumsCount positive integers up to A whose base-B digits add up to C for each query line.Medium4Dynamic programmingMathNo attempts yet1s128 MBJudgeable
TroyanglesCount all centered triangles of `#` cells in an N-by-N grid where row i of a height-h triangle holds 2i-1 cells.Medium4Dynamic programmingMatrixNo attempts yet1s256 MBJudgeable
Turtle ElderPick safe start and end islands in a tree so the sum of values along the path is as large as possible, staying home when the best sum is not positive.Medium4TreeDynamic programmingNo attempts yet5s256 MBJudgeable
Plane Ticket PricingSet each week's ticket price from that week's demand estimates to maximize total revenue over the remaining seats and weeks.Medium4Dynamic programmingNo attempts yet2s256 MBJudgeable
Push-UpsGiven a push-up total equal to the sum of running scores, find the largest final score reachable with the allowed scoring plays.Medium4Dynamic programmingNo attempts yet1s256 MBJudgeable
DiamondsFind the longest subsequence of diamonds in input order with strictly rising weight and strictly falling clarity.Medium4Dynamic programmingNo attempts yet5s256 MBJudgeable
Ambiguous EncodingsCount how many letter strings map to each digit string when A is 1 through Z at 26.Medium4Dynamic programmingStringNo attempts yet1s256 MBJudgeable
Silk RoadChoose N of M days in order for the eastward moves so the sum of distance times daily badness is smallest.Medium4Dynamic programmingNo attempts yet1s256 MBJudgeable
Cow HopscotchCount paths from the top-left cell to the bottom-right cell that move strictly down and right onto cells of the opposite color.Medium4Dynamic programmingMatrixNo attempts yet1s256 MBJudgeable
Palindrome?Answer up to a million queries asking whether a given range of the number sequence is a palindrome.Medium4Dynamic programmingIntervalsNo attempts yet0.5s256 MBJudgeable
Dormitory ReassignmentCount the permutations of N students to rooms in which no student keeps the same room.Medium4CombinatoricsDynamic programmingNo attempts yet1s128 MBJudgeable
DrinksTwo players alternately draw balls without replacement until the first red ball appears, and you compute the chance the first player draws it.Medium4ProbabilityDynamic programming+1No attempts yet2s256 MBJudgeable
Study Time AllocationDistribute up to H study hours among courses with tiered grade costs to maximize the average grade points.Medium4Dynamic programmingNo attempts yet1s256 MBJudgeable
Josephus Problem 3Find the number of the last person remaining after removing every K-th of N people seated in a circle.Medium4MathDynamic programmingNo attempts yet1s16 MBJudgeable
Matrix chain multiplication orderFind the parenthesization of N given matrices that minimizes the total number of scalar multiplications.Medium4Dynamic programmingMatrixNo attempts yet1s256 MBJudgeable
Longest Increasing SubsequenceFind the length of the longest strictly increasing subsequence of the given sequence.Medium4Dynamic programmingBinary searchNo attempts yet1s256 MBJudgeable
Shortest string containing bothFind the length of the shortest string that has both given strings as subsequences.Medium4Dynamic programmingStringNo attempts yet1s256 MBJudgeable
Jump JumpStarting from the first cell, find the fewest rightward jumps bounded by each cell value to reach the last cell, or -1 when unreachable.Medium4Dynamic programmingGreedyNo attempts yet1s256 MBJudgeable
Card GameBoth players alternately take the left or right end card to maximize their own sum, and you compute the first player best total score.Medium4Dynamic programmingGame theoryNo attempts yet1s256 MBJudgeable
Diana and the Golden ApplesPick the apples with the greatest total weight so the extra carrying time stays strictly below her lead over Humperdonkey.Medium4Dynamic programmingNo attempts yet2s256 MBJudgeable
The Knight's Scouting MissionFind the shortest knight distance from (1,1) to (r,c) on an r by c board, count those routes modulo 1000000009, and report None when unreachable.Medium4BFSDynamic programmingNo attempts yet2s256 MBJudgeable
Candy StoreCount the subsets of candy prices whose total is at least C for each test case, modulo 65537.Medium4Dynamic programmingNo attempts yet1s256 MBJudgeable
Horn BlowingCompute the probability that the summed start-up delays of N vehicles with given discrete distributions total at most T seconds.Medium4Dynamic programmingProbabilityNo attempts yet2s256 MBJudgeable
FloydFor every pair of n cities, compute the cheapest directed bus fare from up to 100,000 routes and print 0 where no route connects them.Medium4Shortest pathGraph+1No attempts yet1s256 MBJudgeable
Word Clouds RevisitedPlace N ordered boxes of given widths and heights into width-limited rows to minimize the sum of row heights.Medium4Dynamic programmingPrefix sumNo attempts yet2s256 MBJudgeable
Polynomial GameFor each test case, compute the coefficient of x^N in the product of (1+x+...+x^i) for i from 1 to k.Medium4Dynamic programmingCombinatoricsNo attempts yet1s256 MBJudgeable
Mingyun's SchemeGiven N cards in order, compute the length of the longest strictly increasing subsequence.Medium4Dynamic programmingBinary searchNo attempts yet1s256 MBJudgeable
Box Splitting GameDecide whether the first or second player wins the two-box stone-splitting game from starting counts N and M.Medium4Game theoryDynamic programmingNo attempts yet2s512 MBJudgeable
Stock Purchase PlanFor each test case, decide whether the daily prices contain a strictly increasing subsequence of length K.Medium4Dynamic programmingBinary searchNo attempts yet5s512 MBJudgeable
Longest Increasing Subsequence 2Given up to 1,000,000 numbers, compute the length of the longest strictly increasing subsequence.Medium4Binary searchDynamic programmingNo attempts yet1s512 MBJudgeable
ABC StreetStarting from block 1, hop forward across A, B, C blocks in repeating order to reach block N while minimizing the sum of squared jump lengths.Medium4Dynamic programmingNo attempts yet2s512 MBJudgeable
Cube IV (Small)Given a square grid holding 1 to S squared, find the smallest start of the longest chain that steps to an orthogonal neighbor one higher and report its length.Medium4DFSDynamic programming+1No attempts yet5s512 MBJudgeable
Manage your Energy (Small)Allocate limited energy across ordered activities, regaining R after each up to cap E, to maximize value times energy spent.Medium4Dynamic programmingNo attempts yet5s512 MBJudgeable
Ocean ViewDestroy as few houses as possible so the heights of the houses left standing grow strictly from the lake eastward.Medium4Dynamic programmingNo attempts yet5s512 MBJudgeable
Quake Live Team SplitSplit an even number of players with given skill levels into two equal-size teams so the team totals differ as little as possible.Medium4Dynamic programmingBrute forceNo attempts yet5s512 MBJudgeable
Welcome to Code Jam (Small)Count how many ways the 19-character phrase "welcome to code jam" appears as a subsequence of the input line, and print the last four digits.Medium4Dynamic programmingStringNo attempts yet5s512 MBJudgeable
Road Network of a Perfect Binary TreeFind the minimum number of cars whose vertex-disjoint paths cover every vertex of a perfect binary tree of height H exactly once.Medium4TreeDynamic programming+1No attempts yet2s512 MBJudgeable
CandySum 2^K over all subsets of N candies with K elements, where the empty subset contributes 0, modulo 1,000,000,007.Medium4CombinatoricsMath+2No attempts yet2s512 MBJudgeable
Partitioning a QueueCount compositions of n whose parts avoid the arithmetic progression m, m+k, m+2k, with n up to 30 and up to 10000 test cases.Medium4Dynamic programmingCombinatorics+1No attempts yet2s512 MBJudgeable
CombinationsGiven up to 1000 pairs (n, k), compute the binomial coefficient C(n, k) modulo 10^9+7 for each pair.Medium4CombinatoricsMath+2No attempts yet2s512 MBJudgeable
Lab SchedulePick days to experiment so no two chosen days are within two days of each other, maximizing the sum of visit probabilities.Medium4Dynamic programmingGreedyNo attempts yet2s512 MBJudgeable
HamletGiven a DAG of plot states where each action gives a probability distribution over higher-numbered states, find the best expected value from state 1 and round it to two decimals.Medium4Dynamic programmingProbability+2No attempts yet3s512 MBJudgeable
Minimum energy × delay productChoose a frequency level for each of P programs in order to minimize the total energy times delay product, including a fixed cost per frequency change.Medium4Dynamic programmingImplementationNo attempts yet2s512 MBJudgeable
Hidden PalindromeGiven a word of at most 40 lowercase letters, find the longest palindromic subsequence obtainable by deleting letters from the front and back.Medium4Dynamic programmingString+2No attempts yet2s512 MBJudgeable
The nearest convenience storeGiven an undirected weighted graph with some vertices marked as homes and others as stores, pick the home whose shortest-path distance to the nearest store is smallest, breaking ties by vertex number.Medium4GraphShortest path+2No attempts yet2s512 MBJudgeable
Box PackingGiven box sizes in order, find the longest subsequence where each box is strictly smaller than the next, counting boxes in the pile.Medium4Dynamic programmingBinary search+2No attempts yet2s512 MBJudgeable
Stretch Rope (Small)N is at most 10, so enumerate subsets of bands and find the cheapest subset whose summed intervals contain L and whose total price is within M.Medium4Brute forceArray+2No attempts yet5s512 MBJudgeable
Safe Squares (Small)Count all axis-aligned D by D subgrids of an R by C grid that contain no monster cell.Medium4Dynamic programmingMatrix+2No attempts yet5s512 MBJudgeable
Resource MiningA robot walks from the top-left to the bottom-right cell of an N by M grid using only right and down moves; find the largest number of resource cells it can pass through.Medium4Dynamic programmingMatrix+2No attempts yet2s256 MBJudgeable
Prerequisite CoursesGiven prerequisite pairs between courses, find the earliest semester each course can be completed when unlimited courses may be taken per semester.Medium4GraphTopological sort+2No attempts yet5s256 MBJudgeable
Image quilting (large)Given two grayscale overlap regions of H rows and W columns, pick one column per row so adjacent rows differ by at most one, minimizing the total squared pixel difference.Medium4Dynamic programmingMatrix+1No attempts yet1s512 MBJudgeable
Pizza (Large)Split a tower of N into unit towers, scoring the product of the two parts at each split, and maximize the total score.Medium4GreedyMath+2No attempts yet1s512 MBJudgeable
Chonggang ChonggangRun a single-source shortest path from Jinseo's house, find the nearest type A and type B house, and report the closer type (A wins ties).Medium4Shortest pathGraph+2No attempts yet1s256 MBJudgeable
Multiples of three from 0, 1, and 2 (Large)Count N-digit numbers made only of the digits 0, 1, and 2 that are divisible by 3, with no leading zero, modulo 1e9+9.Medium4Dynamic programmingCombinatorics+1No attempts yet2s256 MBJudgeable
The TA is a sadist!!Given a permutation of 1 to N, find the minimum number of elements to remove so the remaining values increase from front to back.Medium4Dynamic programmingBinary search+2No attempts yet2s256 MBJudgeable
Milk FestivalGiven a sequence of shops selling milk types 0, 1, 2, find the longest subsequence whose values cycle 0,1,2,0,1,2,... in order.Medium4Dynamic programmingNo attempts yet1s256 MBJudgeable
Frog LeapsFind the minimum sum of squared jump distances to travel from the first stop to the last, given sorted positions.Medium4GreedyDynamic programming+1No attempts yet2s512 MBJudgeable
Irrational DivisionTwo players alternately cut whole columns off the west and rows off the south of a p by q chessboard chocolate; compute the optimal final score difference.Medium4Game theoryDynamic programmingNo attempts yet2s512 MBJudgeable
Counting pathsCount paths from the top-left to the bottom-right of a grid, moving only right or down and avoiding obstacle cells, modulo 10^9 + 7.Medium4Dynamic programmingMatrixNo attempts yet2s512 MBJudgeable
Secret of Chocolate PolesCount sequences of dark and white chocolate disks, each 1 cm thick except dark thick disks at k cm, alternating colors, starting and ending dark, with total thickness at most l.Medium4Dynamic programmingCombinatoricsNo attempts yet1s512 MBJudgeable
Maximum of A[j]-A[i]+A[l]-A[k]Given an array, choose four increasing indices i<j<k<l maximizing A[j]-A[i]+A[l]-A[k].Medium4Dynamic programmingArray+1No attempts yet2s512 MBJudgeable
1, 2, 3 Sum 3Count the ordered ways to write n as a sum of 1, 2, and 3, with each test case answered modulo 1,000,000,009.Medium4Dynamic programmingMath+2No attempts yet1s512 MBJudgeable
One, Two, Three Plus FourCount the number of unordered sums of 1, 2, and 3 that add up to a given n, for each test case.Medium4Dynamic programmingCombinatorics+2No attempts yet1s512 MBJudgeable
ÜberwatchGiven a sequence of opponent counts over n time slices and a cooldown m, choose firing times at least m slices apart to maximize total opponents defeated.Medium4Dynamic programmingArray+2No attempts yet2s512 MBJudgeable
Coolest Ski RouteGiven a DAG of slopes with condition values, find the maximum total condition along any downhill path.Medium4GraphDynamic programming+2No attempts yet2s512 MBJudgeable
CombinationCompute N choose R modulo 1,000,000,007 for 0 ≤ R ≤ N ≤ 1,000,000 using a prime modulus.Medium4MathNumber theory+2No attempts yet1s256 MBJudgeable
Gun ControlGiven each lawmaker's defeat cost and compromise value, pick a subset whose costs sum to more than B with minimum total compromise.Medium4Dynamic programmingArrayNo attempts yet2s512 MBJudgeable
Collecting EnergyGiven a row of N weighted beads (N up to 10), remove interior beads one at a time, scoring the product of the neighbors left and right, and maximize the total score.Medium4Dynamic programmingRecursion+1No attempts yet1s512 MBJudgeable
String DiscriminationGiven a target string S and up to 100 words, decide whether S is a concatenation of words from the list, each reusable any number of times.Medium4Dynamic programmingString+1No attempts yet2s512 MBJudgeable
I'm Sick of Fibonacci~Given n, count the total number of calls made by the naive recursive Fibonacci function, modulo 1,000,000,007.Medium4Dynamic programmingRecursion+2No attempts yet1s512 MBJudgeable
Making a PasswordGiven two uppercase strings, find the longest substring that appears in both strings; the answer is unique.Medium4StringBrute force+1No attempts yet1s256 MBJudgeable
My Life Has Math in ItOn an N x N grid (N odd, 3 to 5) holding numbers and operators, find the max and min results of expressions along right/down paths from (1,1) to (N,N), evaluating left to right.Medium4Dynamic programmingImplementation+1No attempts yet1s256 MBJudgeable
Viyott's Stepping Stone CrossingCount the ways to jump from stone 1 to stone N when each jump adds any positive integer, modulo 1e9+7.Medium4MathCombinatorics+2No attempts yet1s256 MBJudgeable
Arranging SoldiersGiven a sequence of N combat powers, find the minimum number of soldiers to remove so the remaining values are in strictly decreasing order.Medium4Dynamic programmingArray+2No attempts yet1s256 MBJudgeable
RUNGiven a directed weighted graph of N cells, one exit cell E, and a time limit T, count how many cells have a path to E within T time units.Medium4GraphShortest path+2No attempts yet2s512 MBJudgeable
Digit SumCount how many starting values between 1 and N can reach N by repeatedly adding the sum of their decimal digits.Medium4Dynamic programmingMath+2No attempts yet2s512 MBJudgeable
Hopscotch 50Given an n by n grid of labels 1 to k, find the minimum total Manhattan distance of a path that visits one tile of each label in order, or -1 if some label is missing.Medium4Dynamic programmingImplementation+2No attempts yet1s512 MBJudgeable