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,683 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Marathon 2Run checkpoints 1 to N in order while skipping at most K middle checkpoints to minimize total Manhattan distance.Medium5Dynamic programmingNo attempts yet1s256 MBJudgeable
Meeting TimeFind the smallest total travel time that both cows can achieve on separate downhill paths from field 1 to field N.Medium5Dynamic programmingGraphNo attempts yet1s256 MBJudgeable
Restore CalculationCount ways to fill each ? in equal-length strings A, B, and C with digits, leading digits nonzero, so A plus B equals C, modulo 1,000,000,007.Medium5Dynamic programmingMathNo attempts yet8s512 MBJudgeable
Two-Area DatabaseRead a fixed sequence of data kinds using a one-slot cache that loads at cost c and serves hits for free, and minimize total read cost.Medium5Dynamic programmingNo attempts yet1s256 MBJudgeable
Pi Day Pie DistributionCount the nondecreasing distributions of n pie pieces among k people with each person getting at least one piece.Medium5Dynamic programmingCombinatoricsNo attempts yet1s256 MBJudgeable
EmpireFind the fastest route from A to B whose total hull damage stays strictly below K.Medium5Shortest pathDynamic programmingNo attempts yet1s256 MBJudgeable
Honey Butter ChipArrange the M extra bags within the N fixed bags and pick no two adjacent bags to maximize the chip total.Medium5Dynamic programmingArrayNo attempts yet5s256 MBJudgeable
Square Piece CutCut an n by m integer-sided rectangle with guillotine cuts into the fewest integer-sided squares.Medium5Dynamic programmingNo attempts yet2s256 MBJudgeable
Card GameTwo piles of N cards are compared from the top, and the program finds the largest score earned by discarding a smaller right card.Medium5Dynamic programmingNo attempts yet1s256 MBJudgeable
Sequence ArtisanFind the largest product of any contiguous block in an array with values from -2 to 2, then report it modulo 1000000007.Medium5GreedyDynamic programming+1No attempts yet1s256 MBJudgeable
Traveling Salesman Tour 2Find the cheapest tour that starts at one city, visits each of N cities exactly once, and returns to the start using the given directed costs.Medium5Dynamic programmingBit manipulation+1No attempts yet2s256 MBJudgeable
Lucky Cookie BakeryAssign each dough ball to one of two ovens with different baking times to minimize the time the slower oven finishes.Medium5Dynamic programmingNo attempts yet5s128 MBJudgeable
Explosive MaterialsSplit conflicting materials into two safe boxes and minimize the fuller box size.Medium5GraphBFS+1No attempts yet3s256 MBJudgeable
The Missing PermutationFill the zeros with the missing values to maximize the length of the longest increasing subsequence.Medium5GreedyDynamic programming+1No attempts yet15s256 MBJudgeable
Attendance AwardCount length-N strings over L, O and A with at most one L and no three consecutive As for each N up to 3000.Medium5Dynamic programmingCombinatoricsNo attempts yet1s256 MBJudgeable
Longest Bitonic SubsequenceGiven a sequence of up to 1000 numbers, find the length of its longest subsequence that strictly rises then strictly falls.Medium5Dynamic programmingNo attempts yet1s256 MBJudgeable
Criboard Max APress A, select all, copy, and paste within N keystrokes to show the most As possible.Medium5Dynamic programmingNo attempts yet1s256 MBJudgeable
Football scorelinesCount the ordered scoring sequences by both teams that reach the given final score under the listed play values, modulo 1000000009.Medium5Dynamic programmingCombinatoricsNo attempts yet2s256 MBJudgeable
Vampire DiceCompute the success probability of scoring at least y points from x exploding ten-sided dice where 8 to 10 score and 10 grants an extra roll.Medium5ProbabilityDynamic programmingNo attempts yet1s256 MBJudgeable
TV WarPick non-overlapping weekly TV programs to maximize the total preference score.Medium5Dynamic programmingSorting+2No attempts yet1s256 MBJudgeable
RobberiesPick a subset of banks that maximizes the stolen money while the combined capture probability stays strictly below the given limit.Medium5Dynamic programmingProbabilityNo attempts yet1s256 MBJudgeable
Combat OddsGiven N independent battles with win chance p, compute the chance that a losing run of at least L occurs.Medium5ProbabilityDynamic programmingNo attempts yet1s256 MBJudgeable
CarrotFor each N, count the steps to reach zero by subtracting one when the pile splits into equal piles of at least two and subtracting two otherwise.Medium5Number theoryDynamic programmingNo attempts yet1s256 MBJudgeable
Atomic ComputerCount the length-y signed-binary strings over -1, 0 and 1 whose digits weighted by powers of two sum to x.Medium5Dynamic programmingBit manipulationNo attempts yet1s256 MBJudgeable
Gimli's GulletPack unlimited servings of M foods into capacity C for the most calories, breaking ties by the lexicographically smallest serving counts.Medium5Dynamic programmingNo attempts yet1s256 MBJudgeable
SurfPick waves with no wait-time overlap so the sum of fun points is as large as possible.Medium5Dynamic programmingSorting+1No attempts yet4s256 MBJudgeable
Feast CoinsCount ways to reach total S with owned coins so that every chosen coin value appears the same number of times.Medium5Dynamic programmingCombinatoricsNo attempts yet3s256 MBJudgeable
King's WalkMove a king n cells over a letter grid to match the motto in as many positions as possible, breaking ties by the smallest coordinate sequence.Medium5Dynamic programmingMatrixNo attempts yet1s256 MBJudgeable
Fruit FeastEat unlimited fruits that add A or B without passing T, using at most one halving, to reach the largest fullness.Medium5Dynamic programmingNo attempts yet2s512 MBJudgeable
Radio ContactJohn and Bessie each walk or wait along their fixed routes to minimize the summed squared distance until both reach their final points.Medium5Dynamic programmingNo attempts yet2s512 MBJudgeable
Circular Barn (Silver)Cows waiting at ring doors walk clockwise to fill each room with one cow at the smallest total squared walking distance.Medium5Dynamic programmingBrute forceNo attempts yet2s512 MBJudgeable
Cleaning the Club Room!Pick exactly M evenings to reset dirt to zero so the sum of daily visitors times dirt since the last cleaning is smallest.Medium5Dynamic programmingPrefix sumNo attempts yet1s128 MBJudgeable
Not So RandomFeed X through N stages that each apply bitwise AND, OR, or XOR with K at given probabilities and report the expected final value.Medium5ProbabilityBit manipulation+1No attempts yet5s512 MBJudgeable
Cube IV (Large)Find the longest run of consecutive room numbers placed in neighboring cells and report its starting number and length.Medium5Dynamic programmingGraph+1No attempts yet5s512 MBJudgeable
Broken Calculator (Small)Split X into factors typed with working digits only, minimizing the total of digit, multiply, and equals presses.Medium5Dynamic programmingRecursion+1No attempts yet5s512 MBJudgeable
Parentheses Order (Small)Print the k-th valid parentheses string of n pairs in lexicographic order for each test case, or report that it does not exist.Medium5Dynamic programmingCombinatoricsNo attempts yet5s512 MBJudgeable
Parentheses Order (Large)Given n and k, output the k-th valid parentheses string of n pairs in lexicographic order, or Doesn't Exist! when fewer than k exist.Medium5Dynamic programmingCombinatorics+1No attempts yet5s512 MBJudgeable
Full Binary TreeGiven a tree with up to 15 nodes, delete as few nodes as possible so the remaining nodes form a full binary tree for some choice of root.Medium5TreeDynamic programming+1No attempts yet5s512 MBJudgeable
Dragon Maze (Small)Find the fewest-step walk from the entrance to the exit of a cell grid and report the most power gathered on such a route.Medium5BFSShortest path+1No attempts yet5s512 MBJudgeable
Dragon Maze (Large)In a grid with blocked cells, walk from the entrance to the exit in the fewest moves and collect the most power among such walks.Medium5BFSDynamic programmingNo attempts yet5s512 MBJudgeable
Diamond Inheritance (Large)Decide whether any pair of classes in each inheritance DAG has two different inheritance paths between them.Medium5GraphTopological sort+1No attempts yet5s512 MBJudgeable
Survivor (Small)Pick which foods to eat and in what order, respecting each shelf life, to maximize total survival time.Medium5BacktrackingDynamic programmingNo attempts yet5s512 MBJudgeable
Bit Count (Small)Given N, split it into nonnegative a and b with a plus b equal to N to maximize the total count of 1 bits in a and b.Medium5Bit manipulationDynamic programmingNo attempts yet5s512 MBJudgeable
Doubly-sorted grid (small)Given a partially filled R by C letter grid with R and C at most 4, count the completions whose rows and columns are non-decreasing modulo 10007.Medium5BacktrackingDynamic programmingNo attempts yet5s512 MBJudgeable
Counting welcome to code jam subsequencesCount subsequences of each input text that spell the 19-character target string, printed as the last four digits.Medium5Dynamic programmingStringNo attempts yet5s512 MBJudgeable
Cheating a Boolean Tree (Small)Given a complete boolean tree with switchable gates, find the minimum number of gate flips so the root evaluates to V.Medium5TreeDynamic programmingNo attempts yet5s512 MBJudgeable
Cheating a Boolean Tree (Large)Given a complete binary tree of AND/OR gates with fixed leaf values, find the fewest changeable gates to flip so the root equals V, or report IMPOSSIBLE.Medium5Dynamic programmingTree+2No attempts yet5s512 MBJudgeable
Longest Increasing Subsequence 3Given a sequence of up to 10^6 integers, find the length of the longest strictly increasing subsequence.Medium5Dynamic programmingBinary searchNo attempts yet3s512 MBJudgeable
Roller CoasterFrom a sequence of column heights, delete columns so the survivors strictly decrease then strictly increase (either part may be empty); output the maximum number of survivors.Medium5Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
String TheoryGiven alternating runs of quote characters, find the largest k for which the whole string is a k-quotation.Medium5Dynamic programmingString+1No attempts yet2s512 MBJudgeable
Inha SuitStarting at height 1, choose one of five moves before each tree so the height lands on a hole, minimizing teleport (T) uses within limit K.Medium5Dynamic programmingGraph+1No attempts yet1s128 MBJudgeable
A Walk Around the Main CampusCount closed walks of exactly D minutes from the Information Science Building in a fixed eight-building graph, modulo 1e9+7.Medium5Dynamic programmingGraph+1No attempts yet1s512 MBJudgeable
Make It One 2Find the fewest operations (divide by 3, divide by 2, or subtract 1) turning N into 1, and print the lexicographically smallest shortest path.Medium5Dynamic programmingBFS+1No attempts yet0.5s512 MBJudgeable
Junseo the Librarian KingGiven book numbers and weights, move the lightest total weight of books so the numbers end up in non-decreasing order.Medium5Dynamic programmingSorting+2No attempts yet2s512 MBJudgeable
Cheating a Boolean TreeIn a tournament-style Boolean tree, flip the fewest changeable AND/OR gates so the root evaluates to V, or report it impossible.Medium5TreeDynamic programmingNo attempts yet2s512 MBJudgeable
Handing out candiesFor every K, count the ways to choose one candy of each brand 1 through K, and print the total over all K.Medium5Dynamic programmingCombinatoricsNo attempts yet2s512 MBJudgeable
Magic PotionGiven a complete graph with edge weights and K potions that halve one trip's time, find the shortest time from city 0 to city 1.Medium5Shortest pathGraph+1No attempts yet2s512 MBJudgeable
Counting Music ScoresCount scores over two pitches and two durations with n seconds total, balanced pitch counts, at least as many long notes as short, and alternating pitches starting low.Medium5CombinatoricsDynamic programming+1No attempts yet2s512 MBJudgeable
Selling CPUsSell up to c CPUs across m ordered merchants, each paying p_i for exactly i CPUs in one deal, to maximize total money.Medium5Dynamic programmingGreedyNo attempts yet2s512 MBJudgeable
MazeBob moves through a multi-graph where each letter opens doors with that label; given the letter sequence, compute the probability he reaches room n, choosing uniformly among available matching doors.Medium5ProbabilityDynamic programming+2No attempts yet2s512 MBJudgeable
Spontaneous TripGiven flight counts between airports, find the most likely airport reached after exactly K random flights starting from ICN.Medium5ProbabilityDynamic programming+1No attempts yet3s256 MBJudgeable
Train Line ConstructionOn an N by N grid with resident counts and blocked cells, find a 4-direction path between two stations minimizing the sum of cell weights along it.Medium5GraphShortest path+2No attempts yet1s64 MBJudgeable
Lucky TicketsCount digit strings of length 2N whose first N digits sum to the same value as the last N digits, modulo 1e9+7.Medium5Dynamic programmingCombinatorics+2No attempts yet2s512 MBJudgeable
EcologyCompute the probability that exactly M of N birds wear a tracker after D days of catching C random birds each day.Medium5Dynamic programmingProbability+1No attempts yet2s512 MBJudgeable
Fibonacci ChickenGiven N, split it into Fibonacci-derived (people, chicken) pairs whose people counts sum to N, and report the minimum and maximum total chickens.Medium5Dynamic programmingMath+2No attempts yet1s128 MBJudgeable
ResortChoose one-day, 3-day, and 5-day passes over a vacation with blocked days so every open day is covered at minimum cost, where 3 coupons buy a free one-day pass.Medium5Dynamic programmingGreedy+1No attempts yet2s512 MBJudgeable
Equal leaf distancesRaise edge weights in a weighted perfect binary tree so every root-to-leaf path has equal length, minimizing the total weight.Medium5TreeGreedy+2No attempts yet1s512 MBJudgeable
Contiguous Sum 2Find the maximum contiguous subarray sum after optionally deleting at most one element from the sequence.Medium5Dynamic programmingArrayNo attempts yet2s512 MBJudgeable
Hard CutsFor each w by h rectangle, find the minimum number of integer-sided squares that tile it exactly.Medium5Dynamic programmingImplementationNo attempts yet2s256 MBJudgeable
Jewelry StoreWith unlimited gems of each of N kinds, list all total values obtainable by choosing exactly K gems.Medium5Dynamic programmingCombinatoricsNo attempts yet5s512 MBJudgeable
Stock exchangeGiven daily prices and a fixed fee per buy, find the maximum total profit when holding at most one share at a time and each share must be sold later.Medium5Dynamic programmingGreedy+2No attempts yet1s512 MBJudgeable
Sum of FactorialsGiven N up to 100000, find the fewest factorials (repeats allowed) whose sum equals N.Medium5Dynamic programmingMath+1No attempts yet1s512 MBJudgeable
VampiresGiven two life totals, a hit threshold and a fixed damage, find the probability that vampire 1 wins a turn-based drain fight.Medium5ProbabilityDynamic programming+1No attempts yet2s512 MBJudgeable
Sentence ReductionGiven tasks with weekday, start and end times, and point values, pick a non-overlapping set that maximizes total points, and report the per-day breakdown.Medium5Dynamic programmingSorting+2No attempts yet2s512 MBJudgeable
Sum Decomposition 2Count ordered K-tuples of integers between 0 and N whose sum is N, modulo 1,000,000,000.Medium5Dynamic programmingCombinatorics+1No attempts yet1s512 MBJudgeable
Good Positions in a PermutationCount permutations of 1..N whose number of positions i with |P_i - i| = 1 equals a given K, modulo 1e9+7.Medium5CombinatoricsDynamic programming+1No attempts yet2s512 MBJudgeable
Alphabet StringInsert the fewest lowercase letters into s so that deleting some letters leaves exactly a through z in order.Medium5Dynamic programmingString+2No attempts yet2s512 MBJudgeable
Gather on the ClockCards sit on a ring; repeatedly stack a card onto its clockwise neighbor for the value difference, and maximize the total score when one card remains.Medium5Dynamic programmingIntervalsNo attempts yet8s512 MBJudgeable
m-ary PartitionsCount the partitions of n into powers of m, for up to 1000 queries with n up to 10000.Medium5Dynamic programmingMath+2No attempts yet2s512 MBJudgeable
Opening Day 2Given wok sizes, each cooking uses one or two distinct woks and produces the sum of their sizes; find the minimum number of cookings summing to exactly N.Medium5Dynamic programmingGreedy+2No attempts yet1s256 MBJudgeable
Grand OpeningGiven N bowls to produce and a multiset of wok sizes, each round uses one wok or two distinct woks of equal size, and you must reach exactly N bowls with the fewest rounds.Medium5Dynamic programmingGreedy+2No attempts yet1s256 MBJudgeable
Banknotes and RouletteSplit banknotes so the two equal-sum groups leave the smallest leftover, then add half of twice that leftover to each person's total.Medium5Dynamic programmingArray+2No attempts yet2s512 MBJudgeable
EmoticonsStarting from one emoticon on screen with an empty clipboard, find the minimum seconds to reach exactly S using copy, paste, and delete-one operations.Medium5BFSGraph+2No attempts yet2s512 MBJudgeable
Score of a SubsequenceFind the maximum over all contiguous subarrays of the weighted sum where the k-th element from the subarray start contributes k times its value.Medium5Dynamic programmingArray+2No attempts yet2s512 MBJudgeable
Connecting Edges 2Given a weighted edge list, pick the order of adding edges that makes the total weight added up to the moment s and t first become connected as small as possible.Medium5GraphSorting+2No attempts yet2s512 MBJudgeable
Vote (Large)Given N supporters of A and M of B in random arrival order, find the probability A leads after every vote; a ballot-problem computation.Medium5CombinatoricsProbability+2No attempts yet5s512 MBJudgeable
Codejamon Cipher (Small)For each enciphered string, count the sentences of vocabulary words whose letter multisets concatenate to it, modulo 1e9+7.Medium5Dynamic programmingHash map+1No attempts yet5s512 MBJudgeable
Slides! (Small)Given B up to 6 and M up to 20, decide if exactly M paths from building 1 to B exist, and print the fixed-rule matrix when possible.Medium5CombinatoricsDynamic programming+1No attempts yet5s512 MBJudgeable
Integer SequenceGiven x, y, the last two digits of A0 and A1, and a large index n, print the last two digits of An where An = x*An-1 + y*An-2.Medium5MathDynamic programming+2No attempts yet0.25s512 MBJudgeable
What Is Dynamic Programming?Count paths from the top-left cell to the bottom-right cell of an n by m grid when each step moves right, down, or diagonally down-right, printed modulo 1e9+7.Medium5Dynamic programmingMatrix+1No attempts yet2s512 MBJudgeable
ResignationGiven each day's consultation length and payment, pick a non-overlapping set of jobs that all finish before day N+1 to maximize total payment.Medium5Dynamic programmingBrute force+1No attempts yet2s512 MBJudgeable
Mario PartyGiven a row of coin values and a die roll range, find the maximum total coins collected on any route that reaches past the star within T turns.Medium5Dynamic programmingNo attempts yet2s512 MBJudgeable
The Other WayCount the number of distinct shortest paths between two towns in a weighted undirected multigraph, modulo 10^9+9.Medium5GraphShortest path+1No attempts yet2s256 MBJudgeable
Image Quilting (Small)Given two H by W grayscale images, choose one pixel per row forming a connected seam (rows shift by at most one column) minimizing the sum of squared pixel differences, and output that minimum.Medium5Dynamic programmingImplementationNo attempts yet1s512 MBJudgeable
Voter DepressionPick non-overlapping story intervals to multiply exposed voters' propensities and maximize the right-minus-left propensity gap.Medium5Dynamic programmingIntervals+1No attempts yet2s512 MBJudgeable
Pony Express (Small)Cities lie on a line with a horse in each; find the minimum time from city 1 to city N, switching horses at intermediate cities, subject to each horse's endurance limit.Medium5Dynamic programmingShortest path+1No attempts yet5s512 MBJudgeable
Tiling a 2 by N wallCount the ways to tile a 2 by N wall with 2x1, 1x2, and 1x1 tiles, modulo 1e9+7.Medium5Dynamic programmingCombinatoricsNo attempts yet2s512 MBJudgeable
From Seoul to GyeongsanChoose walking or cycling for each of N legs so the total time is at most K and the total donation is maximal.Medium5Dynamic programmingBrute force+1No attempts yet2s512 MBJudgeable
Project SchedulingGiven each task's duration and its prerequisite tasks, find the minimum total time to finish the whole project.Medium5Topological sortDynamic programming+2No attempts yet2s512 MBJudgeable
Building a ranchGiven an M by N grid with trees and rocks as obstacles, find the side length of the largest square subgrid that contains no obstacle.Medium5Dynamic programmingMatrix+2No attempts yet1s512 MBJudgeable