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,692 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Burger, French Fries, Soft DrinkCount the ways to cut a B/F/S stream into N consecutive blocks where every block has equal positive counts of each letter, or report Impossible.Medium6Dynamic programmingPrefix sum+2No attempts yet1s128 MBJudgeable
Taxi!Given a bidirectional weighted graph where each road has a traversal time and a fare, find the minimum total time from s to d whose total fare stays within budget r.Medium6GraphShortest path+2No attempts yet1s128 MBJudgeable
Transitive ClosureCount off-diagonal pairs (X, Y) with a directed path from X to Y in a graph of up to 2500 vertices and 10000 edges.Medium6GraphDFS+2No attempts yet1s128 MBJudgeable
Add Them UpGiven counts of each digit 1-9, sum every distinct number formable using each digit at most as often as it appears, modulo 1e9+7.Medium6CombinatoricsDynamic programming+2No attempts yet1s128 MBJudgeable
Euro EfficiencyGiven six coin denominations, find the minimum coins (paid plus change) for each amount from 1 to 100 and report their average and maximum.Medium6Dynamic programmingShortest path+2No attempts yet1s128 MBJudgeable
TriangulationGiven a convex polygon, find the triangulation whose total diagonal length is minimum and report it rounded to two decimals.Medium6Dynamic programmingGeometryNo attempts yet1s128 MBJudgeable
SkewersCount strings of length n over p letters that avoid a given set of forbidden bigrams and trigrams, modulo m.Medium6Dynamic programmingMatrixNo attempts yet1s128 MBJudgeable
CaveGiven a transitive reachability matrix of a DAG, find the minimum number of downward paths needed to cover every node.Medium6GraphGreedy+2No attempts yet1s128 MBJudgeable
Chris MartinGiven a DNA string S of length n, find the smallest possible LCS length between S and any other length-n DNA string.Medium6Dynamic programmingString+2No attempts yet1s128 MBJudgeable
CastleFind a walk from chamber e to chamber p, possibly revisiting chambers with repeated charges, whose total entry cost is exactly b, and print the lexicographically smallest such walk.Medium6GraphDynamic programming+2No attempts yet1s128 MBJudgeable
SpeleologyGiven a DAG where chambers are numbered top to bottom, find the maximum number of downward paths from chamber 1 to chamber n that use distinct first corridors and distinct last corridors.Medium6GraphDynamic programming+2No attempts yet3s512 MBJudgeable
Three-Coloring of Binary TreesGiven a binary tree as a digit specification, color each node red, green, or blue so adjacent nodes differ and siblings differ, then report the maximum and minimum number of green nodes.Medium6TreeDFS+2No attempts yet3s128 MBJudgeable
FrogmanChoose whole cylinders so their combined oxygen and nitrogen meet required volumes while total weight is minimal.Medium6Dynamic programmingGreedyNo attempts yet1s128 MBJudgeable
Cheap TravelsPick a sequence of hotels so consecutive stops are at most 800 km apart, minimizing total price (ties: fewest nights), and also minimizing nights (ties: lowest price).Medium6Dynamic programmingArray+2No attempts yet1s128 MBJudgeable
Lecture Halls ReservationChoose a set of non-overlapping intervals (open at both ends) to maximize the total length covered, given n up to 10000 and times up to 30000.Medium6Dynamic programmingSorting+2No attempts yet1s256 MBJudgeable
Fibonacci WordsCount the occurrences of a given a/b pattern as a contiguous substring of the n-th Fibonacci word, overlaps included.Medium6StringDynamic programming+1No attempts yet1s128 MBJudgeable
KnightsOn a 3 by n board with one possibly blocked square per column, place the maximum number of non-attacking knights and count the number of maximum placements.Medium6Dynamic programmingBit manipulation+2No attempts yet1s128 MBJudgeable
The Concatenation of WordsCount the increasing selections of given words whose concatenation equals a pattern, capped at 1000000, and print the lexicographically smallest selection.Medium6Dynamic programmingString+1No attempts yet1s128 MBJudgeable
TeddiesCount the distinct safe arrangements of up to 152 teddies in four models so that no three consecutive share a letter or a digit, modulo 1000000.Medium6Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable
BackpackChoose a set of items whose total mass is at most p, where each chosen item requires its named lower-indexed prerequisite to be chosen too.Medium6Dynamic programmingTree+1No attempts yet1s128 MBJudgeable
Acyclic DecompositionGiven a directed graph, find the minimum number of acyclic subgraphs needed to partition all its edges.Medium6GraphGreedy+2No attempts yet2s512 MBJudgeable
DrillingGiven drilling costs at n positions along a segment, find the minimum worst-case total time to locate the reservoir boundary using adaptive queries.Medium6Dynamic programmingBinary search+2No attempts yet1s128 MBJudgeable
ChessAn n by n board with n rooks, at most one per row and column, and the placement unchanged after a 90 degree rotation is given. Count the number of such placements for n up to 50000.Medium6CombinatoricsMath+1No attempts yet2s512 MBJudgeable
BugFind the shortest route from city 1 to city n whose total length is odd, or report 0 if none exists.Medium6GraphShortest path+1No attempts yet1s128 MBJudgeable
ConferenceGiven per-presentation ticket prices, room capacity and room rent, and group reservations, choose how many tickets to cancel to maximize revenue minus rent.Medium6Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
BracketsGiven n and k, print the k-th correct bracket sequence of length 2n in lexicographic order.Medium6CombinatoricsDynamic programming+1No attempts yet1s128 MBJudgeable
InversionsCount permutations of size n that have exactly k inversions, modulo 30011, using the Mahonian number recurrence with a sliding window over prefix sums.Medium6Dynamic programmingCombinatorics+2No attempts yet1s128 MBJudgeable
Round-Table HandshakesCount matchings on an n-person cycle where each person shakes at most one neighbor's hand, and print the count modulo 10.Medium6Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable
MatchingsGiven a tree, compute the size of its maximum matching and count how many maximum matchings exist, modulo m.Medium6Dynamic programmingTree+2No attempts yet3s128 MBJudgeable
GenomesFind the length of the longest common subsequence of up to 20 permutations of size up to 500.Medium6GraphTopological sort+1No attempts yet1s128 MBJudgeable
Bit SharkFind the length of the string left after repeatedly deleting the second half of any even-length palindrome, choosing deletions to maximize bits eaten.Medium6StringGreedy+1No attempts yet1s128 MBJudgeable
Signed Binary ExpansionGiven a decimal integer with up to 500 digits, find the smallest possible count of nonzero digits in a signed binary expansion.Medium6Dynamic programmingGreedy+2No attempts yet1s128 MBJudgeable
Bracket ExpressionsThe task is to count substrings of a bracket string that are correct bracket sequences.Medium6StackDynamic programmingNo attempts yet1s512 MBJudgeable
Balancing the ScaleRemove the fewest bricks from the tops of the towers so the total weight on the left pan equals the total on the right.Medium6Dynamic programmingNo attempts yet1s512 MBJudgeable
Number of Longest Increasing SubsequencesCount how many strictly increasing subsequences of the given sequence attain the maximum possible length, modulo m.Medium6Dynamic programmingSegment treeNo attempts yet1s128 MBJudgeable
Longest Common Increasing SubsequenceFind the length of the longest strictly increasing sequence that is a subsequence of both given sequences.Medium6Dynamic programmingArrayNo attempts yet1s128 MBJudgeable
Paper FoldingRepeatedly fold the left part of a binary strip over the right where symbols match and find the shortest reachable length.Medium6Dynamic programmingString+1No attempts yet1s128 MBJudgeable
Paweł i GawełTwo players alternate moving a pawn across a grid, swapping floors whenever it enters a marked cell, each trying to hold the upper floor at the end.Medium6Game theoryDynamic programming+1No attempts yet3s128 MBJudgeable
DominoTopple one domino left or right and count how many fall in the longest chain reaction.Medium6Dynamic programmingBinary search+1No attempts yet1s128 MBJudgeable
Formula RaceFinish exactly N laps with refueling pit stops and two tire types, both used at least once, in minimum total time.Medium6Dynamic programmingShortest pathNo attempts yet1s128 MBJudgeable
Bar ArrangementCount permutations of 1 to n with exactly l left-to-right maxima and r right-to-left maxima for each test case.Medium6Dynamic programmingCombinatoricsNo attempts yet1s256 MBJudgeable
PeriodSplit string x into pieces to minimize the largest edit distance between y and any piece.Medium6Dynamic programmingStringNo attempts yet1s128 MBJudgeable
Practice SeasonBoth teams insert rest days into their fixed city orders to minimize combined stadium and hotel costs.Medium6Dynamic programmingString matchingNo attempts yet2s128 MBJudgeable
CubeCut a W by L by H integer block into integer-sided cubes with the fewest cuts and output the number of cubes.Medium6Dynamic programmingRecursionNo attempts yet10s128 MBJudgeable
DeliveryMerge two ordered delivery lists starting from the origin to minimize total Euclidean travel distance without returning.Medium6Dynamic programmingNo attempts yet1s128 MBJudgeable
Golf CoursesPick course sites and assign every client to a built course to minimize building plus connection costs within capacities.Medium6Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
GameTwo players alternately add to S within a range set by the current parity, and whoever first reaches F loses, so decide if the first player can force a win.Medium6Game theoryDynamic programming+1No attempts yet1s128 MBJudgeable
Contest Problem AssignmentSplit up to ten contest problems among three members with individual time limits to solve the largest possible count.Medium6Dynamic programmingBit manipulationNo attempts yet1s128 MBJudgeable
Prime CavesStarting from cave n on a spiral-numbered grid, descend down-left, down, or down-right to collect the most prime-numbered caves.Medium6Dynamic programmingNumber theory+1No attempts yet1s128 MBJudgeable
Powerbase FormatCount how many integers in each query range lack a powerbase form d1^1+...+dL^L within the length bound using the given digits.Medium6BacktrackingDynamic programming+1No attempts yet1s128 MBJudgeable
Superstitious Helicopter PilotsSimulate the pilot's greedy rule by checking reachability past forbidden points at each step and print the resulting hop sequence in run-length form.Medium6Dynamic programmingGreedyNo attempts yet1s128 MBJudgeable
YahtzeeAssign thirteen dice rolls to thirteen Yahtzee categories, including the upper-section bonus, to maximize the total score.Medium6Dynamic programmingBrute force+1No attempts yet1s128 MBJudgeable
Lifeboat BalancingSplit all passengers into two boats with equal head counts (off by one when N is odd) so the two total weights differ as little as possible.Medium6Dynamic programmingNo attempts yet1s128 MBJudgeable
WimbledonCompute the expected match length in minutes from each player's chance of winning a game on serve under best-of-five tennis scoring.Medium6ProbabilityDynamic programmingNo attempts yet1s128 MBJudgeable
ChompDecide whether each 3-row Chomp position is winning and output a move to a losing position.Medium6Game theoryDynamic programmingNo attempts yet1s128 MBJudgeable
Klingon WarfarePick one subclan from each ordered clan tree so the pair matches in style, child count and sibling order with the largest size.Medium6TreeHash map+1No attempts yet5s128 MBJudgeable
Booking ErrorAdd the fewest new segments to the booked ticket so travel from start to destination uses the smallest number of stops the network allows.Medium6Shortest pathDynamic programming+1No attempts yet1s128 MBJudgeable
Largest Subsequence NumberPick digits from N in order, without a leading zero, to form the largest value that leaves remainder R when divided by Q.Medium6Dynamic programmingString+1No attempts yet3s128 MBJudgeable
Joy of the Cylinder GameChoose one cell in every row of the cylindrical grid within the step limit so the total is largest, and print the smallest best path.Medium6Dynamic programmingSliding windowNo attempts yet1s128 MBJudgeable
Join the ConversationFind the longest chronological message chain where each message mentions the previous author, breaking ties by smallest indices.Medium6Dynamic programmingHash map+1No attempts yet2s128 MBJudgeable
Mario KartMove between stations when a subset of coins meets the cost limit and matches the distance, and find the fewest moves from the first to the last station.Medium6Dynamic programmingGraph+1No attempts yet1s128 MBJudgeable
Stone Game 8Count pile sizes up to M where the second player wins a take-away game with a fixed move set.Medium6Game theoryDynamic programming+1No attempts yet1s128 MBJudgeable
Genetically Modified AppleInsert priced letters into a DNA string so a given gene appears as a contiguous block at minimum total cost.Medium6Dynamic programmingString matchingNo attempts yet1s128 MBJudgeable
BitTorrentChoose the most files whose covering fixed-size pieces fit in the bandwidth budget, where a piece shared by files is paid once.Medium6Dynamic programmingPrefix sumNo attempts yet2s128 MBJudgeable
Sum of LIS lengths over every consecutive subsequenceSum the LIS lengths of all contiguous subarrays for each test case of distinct integers.Medium6Dynamic programmingBinary search+1No attempts yet1s128 MBJudgeable
BoosterCompute how many minutes up to K halve-one-edge boosters save on the fastest route from district 1 to district N.Medium6Shortest pathDynamic programmingNo attempts yet1s128 MBJudgeable
Singapore TourStart at C, collect values from up to 14 grid spots with per-step cost 2, and return for the maximum net score.Medium6Dynamic programmingBFS+1No attempts yet2s512 MBJudgeable
LazycatFind the shortest walk on a grid with walls that starts at S, visits every food cell, then ends at the bed.Medium6Dynamic programmingBFS+1No attempts yet2s512 MBJudgeable
StreetChoose up to k non-overlapping blocks of at most t lots to maximize total block length times its minimum height limit.Medium6Dynamic programmingIntervalsNo attempts yet2s512 MBJudgeable
GenomeFind the length of the longest sequence that appears as a subsequence in every given permutation.Medium6GraphDynamic programmingNo attempts yet2s512 MBJudgeable
Filling a 4 × n Rectangle with DominoesCount the tilings of a 4 by n board with dominoes and print the count modulo 1000 without leading zeros.Medium6Dynamic programmingCombinatoricsNo attempts yet1s128 MBJudgeable
Longest Arithmetic ProgressionFind the length of the longest subsequence of the given sorted list that forms an arithmetic progression.Medium6Dynamic programmingArrayNo attempts yet2s1024 MBJudgeable
Scout OutingScouts split along every DAG trail and regroup at each station; report the last arrival time, the total waiting spread, and the stations with departure slack.Medium6Topological sortDynamic programming+1No attempts yet1s128 MBJudgeable
Secret CodeCount the sequences of operations that build the given string from a source of length at least 2 by gluing each string to a copy missing one end character.Medium6Dynamic programmingString matching+1No attempts yet1s128 MBJudgeable
Mooo MooFind the fewest cows whose breed volumes explain the recorded volumes when each field spills its total minus one into the next field.Medium6Dynamic programmingGreedyNo attempts yet1s128 MBJudgeable
OdometerCount the integers from X to Y with one digit occupying at least half of their decimal digits, ignoring leading zeros.Medium6Dynamic programmingCombinatorics+1No attempts yet1s128 MBJudgeable
IOI ManjuChoose boxes and fill them with the priciest manju so packed value minus box cost is as large as possible.Medium6Dynamic programmingSorting+1No attempts yet1s256 MBJudgeable
OrchardPick one rectangle for Bert to minimize the bananas left outside it plus the apples inside it.Medium6MatrixPrefix sum+1No attempts yet2s512 MBJudgeable
Decreasing Sequences of PointsCount sequences of lattice points on the diagonals x+y=a_i with nondecreasing x and nonincreasing y.Medium6Dynamic programmingPrefix sumNo attempts yet1s256 MBJudgeable
Lazy FoxStarting from the origin, visit neighbors so each hop is strictly shorter than the last and collect the maximum number of treats.Medium6Dynamic programmingSorting+1No attempts yet1s256 MBJudgeable
KCM TravelFind the fastest route from airport 1 to airport N using flights with costs and times without exceeding budget M, or report that it is impossible.Medium6Dynamic programmingShortest path+1No attempts yet3s256 MBJudgeable
Driving license testMove only right and down from the top left corner to the bottom right corner with at most G fuel to arrive as early as possible.Medium6Dynamic programmingGraphNo attempts yet2s256 MBJudgeable
Ancient Cave ExpeditionFrom cave 1, choose a route that only moves deeper to maximize treasure values minus tunnel costs, breaking profit ties by lexicographic order.Medium6Dynamic programmingTopological sort+1No attempts yet1s256 MBJudgeable
Lift ProblemsDecide the lift stops for given per-floor student counts to minimize total annoyance from stops and skipped floors.Medium6Dynamic programmingPrefix sumNo attempts yet1s256 MBJudgeable
Help CupidGiven N time zones, split everyone into pairs to minimize the total circular hour difference.Medium6Dynamic programmingSortingNo attempts yet3s256 MBJudgeable
Matryoshka DollsChoose and nest the most dolls so each doll carries its own weight plus every doll inside it.Medium6Dynamic programmingSortingNo attempts yet1s256 MBJudgeable
Number Picking GameAhyeon removes interior numbers one at a time, scores each pick plus its live neighbors, and maximizes the total score.Medium6Dynamic programmingIntervalsNo attempts yet1s256 MBJudgeable
Unicycle countingFind the smallest number of arithmetic progressions that leave marks exactly at the observed road positions.Medium6Dynamic programmingBit manipulation+2No attempts yet2s256 MBJudgeable
Digi Comp IIBalls fall through a DAG of toggle switches that flip after each visit, and the task is to report the final state of every switch.Medium6Topological sortDynamic programmingNo attempts yet7s256 MBJudgeable
MAFIJAEach of N players accuses one other, and mobsters never accuse mobsters, so find the largest set with no internal accusation.Medium6Dynamic programmingGraphNo attempts yet1s256 MBJudgeable
Dorm PartyChoose up to K building resets over N daily move-ins to minimize the sum of current occupancy counts at each arrival.Medium6Dynamic programmingGreedy+1No attempts yet1s256 MBJudgeable
Bob's House SiteCount the subrectangles of an N by M elevation grid whose covered cells all have equal height.Medium6StackMatrix+1No attempts yet1s64 MBJudgeable
Hill NumbersGiven N with up to 70 digits, count hill numbers smaller than N, or print -1 when N is not one.Medium6Dynamic programmingCombinatoricsNo attempts yet5s256 MBJudgeable
Increasing NumbersFor each given number, print -1 unless its digits never decrease, else count smaller integers whose digits never decrease.Medium6CombinatoricsDynamic programmingNo attempts yet5s256 MBJudgeable
Bulletproof Glass Testing BudgetCompute the minimum worst-case budget to find the exact breaking distance when each bullet and each broken pane costs money.Medium6Dynamic programmingNo attempts yet1s256 MBJudgeable
Web Service DependenciesCount the launch orders that place each container after all of its dependencies for each configuration.Medium6Dynamic programmingTopological sort+1No attempts yet1s256 MBJudgeable
Meeting TimeBessie and Elsie each choose a downhill route from field 1 to field N with their own edge times so both arrive at the same earliest moment.Medium6Dynamic programmingGraphNo attempts yet1s256 MBJudgeable
FouadCount distinct numbers divisible by 7 formed by using each given digit exactly once with no leading zero.Medium6Dynamic programmingCombinatorics+1No attempts yet1s256 MBJudgeable
Cow HopscotchCount paths from the top-left to the bottom-right cell that step strictly down and right onto a different value, modulo 1000000007.Medium6Dynamic programmingPrefix sum+1No attempts yet1s256 MBJudgeable
Bessie's Birthday BuffetChoose patches of strictly increasing quality and walk between them to maximize total quality gained minus E per step.Medium6Dynamic programmingShortest path+1No attempts yet1s256 MBJudgeable