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,779 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
AB StringFind the length-N A/B string whose number of (A before B) pairs equals K, choosing the lexicographically smallest such string.Medium4GreedyCombinatorics+1No attempts yet2s512 MBJudgeable
Wolves and Proper WordsGiven a word of w, o, l, f, decide whether it is a concatenation of blocks w^n o^n l^n f^n for n >= 1.Medium4StackGreedyNo attempts yet2s512 MBJudgeable
Important TestFor each variant, find the longest prefix solvable in t minutes given he may replace at most one task time with t0. Since order is fixed, choose the single task in that prefix whose copying saves the most time.Medium4ArrayPrefix sum+1No attempts yet2s512 MBJudgeable
Do Not Touch AnythingGiven an R by C grid and an N by N square, find the fewest squares needed to cover the whole grid, allowing overhang and overlap.Medium4MathGreedyNo attempts yet1s32 MBJudgeable
HoneyGiven N hives with honey amounts, a pot of capacity M, and at most K trips, maximize the total honey collected.Medium4GreedySorting+1No attempts yet1s64 MBJudgeable
Harps and TailsFlip any subset of columns of an H/T grid; find the maximum number of rows that can be made all-H.Medium4Hash mapGreedy+2No attempts yet2s512 MBJudgeable
Stacking BlocksGiven a 0/1 top view plus front and side height maxima, output the tallest cube stack arrangement matching all three views, or -1.Medium4GreedyMatrix+1No attempts yet1s128 MBJudgeable
RearrangeChoose an ordering of the array, subtract elements from n in that order until n drops to 0 or below, and report the smallest achievable result.Medium4GreedySortingNo attempts yet1s512 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
Card StringGiven uppercase letters taken left to right, each new card is placed at the front or back of the growing string; find the lexicographically smallest result.Medium4GreedyString+2No attempts yet1s256 MBJudgeable
Battle SimulationRead a monster attack string and output the mech's counters, merging each earliest triple of R, B, L into one C.Medium4StackString+1No attempts yet2s512 MBJudgeable
Sticky SituationGiven N stick lengths, decide whether some three of them can form a triangle with positive area.Medium4SortingGreedyNo attempts yet2s512 MBJudgeable
Fridge MagnetsGiven a multiset of digit magnets, find the smallest positive integer that cannot be assembled from them, where the answer can exceed 64-bit range.Medium4GreedyMath+2No attempts yet2s512 MBJudgeable
Stick GameGiven counts of sticks of distinct lengths, find the maximum number of rectangles (squares allowed) that can be built using each stick at most once.Medium4GreedySortingNo attempts yet2s512 MBJudgeable
Mismatched SocksGiven counts of socks per color, find the maximum number of pairs where each pair uses two different colors and every sock is in at most one pair.Medium4GreedyMath+1No attempts yet2s512 MBJudgeable
Pokemon TradingWith a fixed budget, buy on one day and sell on a later day to maximize profit; report the best result rounded to two decimals.Medium4ArrayGreedy+1No attempts yet0.3s4 MBJudgeable
Delete and Append SortEach operation moves one element to the end. Find the minimum number of such moves needed to sort the array.Medium4GreedySortingNo attempts yet2s512 MBJudgeable
Merging Files 3Given K file sizes, find the minimum total cost of repeatedly merging two files where each merge costs the sum of their sizes.Medium4HeapGreedyNo attempts yet2s512 MBJudgeable
Contest ScoreSimulate reading problems in order but solving the shortest available one first, keeping at most k in memory, and report the total submission time.Medium4SimulationHeap+1No attempts yet2s512 MBJudgeable
Tandem BicyclePair each Dmojistan rider with a Pegland rider to minimize or maximize the sum of the larger speed in each pair.Medium4GreedySorting+2No attempts yet2s512 MBJudgeable
HyperloopFor odd N, print (N-1)/2 Hamiltonian cycles on the complete graph of N cities that partition all edges, using the given seat-walk construction.Medium4GreedyMath+2No attempts yet1s128 MBJudgeable
TunnelGiven the entry order and exit order of N cars through a tunnel, count how many cars must have overtaken another car.Medium4ArrayHash map+2No attempts yet2s512 MBJudgeable
Packing snack sticksGiven n and m, decide whether an n by m grid can be tiled exactly with 3-cell straight bars and L trominoes that may be rotated.Medium4MathGreedy+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
Christmas GiftsProcess visits in order: depots add gifts to Santa's collection, and each child takes the largest gift currently held.Medium4HeapSimulation+1No attempts yet2s512 MBJudgeable
Merging SlimesMerge N slimes two at a time, scoring the product of merged sizes, and maximize the total score.Medium4GreedySortingNo attempts yet2s512 MBJudgeable
Build a treeConstruct a tree on n nodes with exactly m leaves whose sorted edge list is lexicographically smallest, and print its n-1 edges.Medium4TreeGreedy+2No attempts yet2s512 MBJudgeable
Close Match (Small)Fill in the question marks in two equal-length digit strings to minimize the absolute difference between the values, breaking ties by minimizing the first then the second.Medium4Brute forceImplementation+2No attempts yet5s512 MBJudgeable
The Last Word (Large)Insert each letter of S at the front or back of the growing word so the final string is as large as possible lexicographically.Medium4GreedyString+1No attempts yet5s512 MBJudgeable
Revenge of the Pancakes (Small)Given a stack of pancakes as a + and - string, find the fewest top-prefix flips that make every pancake happy side up.Medium4GreedyStringNo attempts yet5s512 MBJudgeable
Revenge of the Pancakes (Large)Given a stack of pancakes as a string of + and -, find the minimum number of top-prefix flips needed to make every pancake show its happy side.Medium4GreedyString+1No 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
Cow TippingGiven an N by N grid of 0s and 1s, find the minimum number of upper-left rectangles to toggle so all cells become 0.Medium4GreedyArray+2No attempts yet2s512 MBJudgeable
Point CardGiven M cards with A wins out of 2N cells, pay 1 yen per flipped stamp to make at least M-1 cards hold N or more wins; minimize total cost.Medium4GreedySorting+1No attempts yet2s512 MBJudgeable
Wookje Is a Devoted Son!!Given edge costs of a cycle of n villages, find the minimum total cost for three travelers starting at one village to collectively visit every village.Medium4GreedyImplementation+2No attempts yet2s512 MBJudgeable
GwailnoriGiven each segment's bot cycle of a seconds with b active, find the earliest time to traverse all N segments in order, waiting whenever a segment is active on arrival.Medium4SimulationMath+2No attempts yet2s512 MBJudgeable
Yin and Yang StonesGiven a circular string of black and white stones, decide whether repeated merges can reduce it to one black and one white stone.Medium4StringGreedy+1No attempts yet2s512 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
Wookje's Dinner WheelGiven a sequence where each menu number appears exactly twice, find the maximum number of values seen once but not yet seen twice at any point.Medium4ArrayHash map+2No attempts yet2s256 MBJudgeable
MultiMaxGiven n cards with values in [-1000, 1000], pick two or three so their product is maximized.Medium4SortingGreedy+1No attempts yet1s512 MBJudgeable
Pizza BoxesGiven a grid of distinct pile heights, find how many boxes can be removed while keeping the per-row and per-column maxima unchanged.Medium4ArrayGreedy+2No attempts yet1s512 MBJudgeable
Party GamesFor each test case, find the shortest string that splits the sorted guest names into two equal halves, choosing the alphabetically first if several have that length.Medium4StringSorting+1No attempts yet2s512 MBJudgeable
Bathroom Stalls (Small1)Simulate K people choosing stalls by a fixed farthest-from-others rule and report the distances around the stall the last person takes.Medium4SimulationImplementation+2No attempts yet5s512 MBJudgeable
Steed 2: Cruise Control (Small)Given horses ahead on a one-way road that slow to match slower horses they catch, find the fastest constant speed Annie can hold to her destination without ever passing one.Medium4MathImplementation+2No attempts yet5s512 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
Complete Naebbirac's sequenceGiven a multiset of values 1..K, find the single add, remove, or replace operation that makes every value appear equally often.Medium4ArrayHash map+1No attempts yet1s1024 MBJudgeable
Auxiliary ProjectChoose any multiset of digits whose total lit segments equals n, and maximize the sum of the digits.Medium4GreedyMathNo attempts yet3s512 MBJudgeable
Frosh WeekGiven task durations and quiet-interval lengths, each between 100000 and 199999, pair tasks with intervals that fit them and maximize the number of completed tasks.Medium4GreedyTwo pointers+2No attempts yet4s512 MBJudgeable
ZigZagGiven K words and N letters, output for each letter the word starting with it that has been used fewest times, breaking ties alphabetically.Medium4SortingHash map+2No attempts yet2s64 MBJudgeable
Street LightsGiven existing street lights that each cover K metres to both sides, find the minimum number of extra lights needed to light every metre from 1 to N.Medium4GreedySorting+2No attempts yet1s64 MBJudgeable
How to Eat at a BuffetGiven a plate area and items with value per area and available area, pick fractions to maximize total value on the plate.Medium4GreedySortingNo attempts yet2s512 MBJudgeable
Coloring IntervalsGiven n closed intervals with distinct endpoints, find the minimum number of colors so that overlapping intervals get different colors.Medium4SortingIntervals+2No attempts yet3s512 MBJudgeable
Out of PlaceGiven a row that came from a sorted row with one cow moved, find the minimum number of arbitrary swaps to sort it.Medium4SortingGreedy+1No attempts yet2s512 MBJudgeable
GlenGiven a target pattern of marks on an N by M grid, produce the fixed boustrophedon walk that flips tiles down-and-back to match the pattern.Medium4SimulationImplementation+2No attempts yet1s256 MBJudgeable
HoofballSort cows by position, then find the minimum number of starting balls so every cow receives the ball at least once under the nearest-cow passing rule.Medium4SortingGraph+1No attempts yet2s512 MBJudgeable
Taming the HerdGiven a partial daily log of days-since-breakout values with a breakout on day 1, find the minimum and maximum possible breakouts.Medium4GreedyArray+2No attempts yet2s512 MBJudgeable
Lemonade LineGiven each cow's maximum tolerated queue length, choose an arrival order that minimizes how many cows end up waiting in line.Medium4GreedySorting+2No attempts yet2s512 MBJudgeable
Harmonic numberCompute the numerator and denominator of the harmonic number H_N as an irreducible fraction for N up to 10000.Medium4MathNumber theory+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
You Are Fired!Pick at most k employees whose salaries sum to at least d, minimizing the number fired, or report that it cannot be done.Medium4GreedySorting+1No attempts yet2s512 MBJudgeable
It's Time for a MontageEach day every hero gains 1 power; find the minimum number of days until the heroes win the ordered rival showdown.Medium4ImplementationGreedy+2No attempts yet2s512 MBJudgeable
Gahui and the 3-Step High NoteGiven a sequence of notes and an arithmetic progression with first term A and difference D, find the largest number of terms of the progression that appear as a subsequence in order.Medium4GreedyArray+2No attempts yet1.5s256 MBJudgeable
HackathonPartition N students into the fewest teams so each student's team size does not exceed their limit Xi.Medium4GreedySorting+1No attempts yet2s512 MBJudgeable
Card PickingGiven N cards with M front O's, choose exactly K off sameSymbol cards get an O on the back and the rest an X to maximize front-back matches.Medium4MathGreedy+1No attempts yet1s512 MBJudgeable
Roll CakeGiven up to M cuts across cakes of length at most 1000, maximise how many length-10 pieces you can cut out of them.Medium4MathGreedy+1No attempts yet2s512 MBJudgeable
EagleEach day pick one cell, route from an edge, empty every cell passed over, and lose one sheep per cell at night; maximize the sheep eaten.Medium4SimulationGreedyNo attempts yet2s512 MBJudgeable
SpaceshipReorder n enemy powers so that the last one equals the sum of all the others.Medium4MathSorting+2No attempts yet2s512 MBJudgeable
Martian VolleyballGiven a volleyball score k x y, find the fewest remaining balls until one team wins by reaching k with a 2-point lead.Medium4MathGreedy+1No attempts yet2s512 MBJudgeable
Code CleanupsGiven days of dirty pushes, clean up as late as possible at day end so dirtiness (sum of push ages) stays below 20; count cleanup phases.Medium4SimulationGreedyNo attempts yet1s512 MBJudgeable
Drawing LinesGiven N segments on a number line, find the total length of their union, counting overlaps once and printing it as an integer.Medium4SortingIntervals+2No attempts yet1s256 MBJudgeable
Planet ConnectionGiven a complete symmetric cost matrix, find a minimum spanning tree connecting all planets and output its total maintenance cost.Medium4Minimum spanning treeGraph+2No attempts yet1s256 MBJudgeable
SnakebirdGiven N fruits at heights h_i and a snake of length L, grow by eating any fruit of height at most the current length and output the maximum length reached.Medium4GreedySorting+1No attempts yet1s128 MBJudgeable
Make the Largest NumberGiven up to 1000 non-negative integers, order the pieces so their concatenation is the largest possible number, and print it without leading zeros.Medium4GreedySorting+1No attempts yet2s512 MBJudgeable
Heroes of the Storm ProgamerGiven N character levels and a total increase K, raise levels to maximize the minimum of the chosen sequence.Medium4GreedySorting+1No attempts yet2s512 MBJudgeable
Enviska's SoulGiven N people ahead and jump sizes a and b, find the smallest time to reach the front using zero-time jumps or waiting.Medium4MathGreedy+1No attempts yet2s512 MBJudgeable
A Study on GroupsSplit the N integers into M groups whose sizes differ by at most one, then compute the smallest and largest possible sums of the group minima.Medium4ArrayGreedy+2No attempts yet1s512 MBJudgeable
InflationPair canister amounts with balloon sizes 1 to n so the minimum fill fraction is as large as possible without exceeding any capacity.Medium4GreedySortingNo attempts yet2s512 MBJudgeable
Judging DivisionalsGiven ranked teams with a division and university, apply two selection steps with university limits and output the 12 advancing teams by rank.Medium4SimulationImplementation+2No attempts yet1s512 MBJudgeable
LapsGiven per-minute track positions from a monotone run on an n-metre loop, find the smallest possible total forward distance modulo n in laps.Medium4ArrayMath+2No attempts yet1s512 MBJudgeable
Easy ChessFind a path of exactly n rook moves on an 8x8 board from a1 to h8 that visits n+1 distinct cells.Medium4ImplementationBrute force+2No attempts yet2s512 MBJudgeable
LazylandEach of n workers wants one of k jobs and costs b_i to reassign. Keep one worker per chosen job and reassign the cheapest extras to cover every missing job. Return the minimum total cost.Medium4GreedySorting+1No attempts yet2s512 MBJudgeable
Devil GameFind a dictionary word containing the original word as a subsequence and maximize mood-killing degree per inserted letter, breaking ties by input order.Medium4StringTwo pointers+1No attempts yet1s256 MBJudgeable
GuruGuruCount disjoint substrings of an L/R command string that complete one full clockwise rotation from north with the required non-north directions visited.Medium4StringGreedy+1No attempts yet2s512 MBJudgeable
An I for an EyeApply a fixed table of text abbreviations to each line, scanning left to right and always taking the longest match at a position, with case handling.Medium4StringSimulation+2No attempts yet2s512 MBJudgeable
Grass PlantingGiven a tree with N fields, plant grass so that no two fields at distance one or two share a type, and output the minimum number of types needed.Medium4TreeGreedy+1No attempts yet2s512 MBJudgeable
JarvisPick one integer X added to every factory frequency so that the count of indices with Ai + X = Bi is as large as possible.Medium4Hash mapArray+2No attempts yet1s512 MBJudgeable
SortingGiven an array, count how many single elements can be removed so that the remaining N-1 elements are in nondecreasing order.Medium4ArrayImplementation+2No attempts yet1s512 MBJudgeable
Hide and Seek 6Given Subin's position S and the positions of N siblings, find the largest step size D such that repeated moves of +D or -D from S can reach every sibling.Medium4MathNumber theory+2No attempts yet1s512 MBJudgeable
Overflowing FandomGiven N intervals during which fans are at school, find the minimum length of a single visit window that meets every interval.Medium4IntervalsGreedy+2No attempts yet1s256 MBJudgeable
But can you do it in 0.5x A presses?Given the A-press cost of each stage as a multiple of 0.5, find the minimum total presses to clear all stages in order, since holding A carries between stages.Medium4GreedyMath+1No attempts yet1s512 MBJudgeable
BitberryGiven P bits, Q berries, and exchange rates A, B, C, D, find the maximum number of bitcoins obtainable, where each bitcoin costs 1 bit and 1 coin.Medium4MathGreedy+1No attempts yet1s1024 MBJudgeable
6789Each cell holds a card 6, 7, 8, or 9; turning a card rotates it (6 and 9 swap, 8 and 7 stay). Find the minimum number of turns so the grid stays the same after a 180-degree rotation, or -1 if impossible.Medium4ImplementationGreedy+1No attempts yet1s1024 MBJudgeable
And the Winner Is... Ourselves!Given 11 problems that are all solved, choose the solving order that minimizes total penalty, where each problem contributes its finish time plus 20 times its wrong submissions.Medium4GreedySorting+2No attempts yet4s1024 MBJudgeable
ArchitectureGiven the R row maxima and C column maxima of a grid, decide whether any grid of heights can realize both sets of maxima.Medium4GreedyImplementation+2No attempts yet1s512 MBJudgeable
Inquiry ISplit the array into a prefix and a suffix at some index k; maximize the sum of squares of the prefix times the sum of the suffix.Medium4Prefix sumArray+2No attempts yet3s512 MBJudgeable
On-Screen KeyboardGiven a grid keyboard with a highlighted cell, find the total minimum button presses to type a string, where each character's cost is the Manhattan distance plus one for OK.Medium4ImplementationArray+2No attempts yet2s512 MBJudgeable
Pocket MoneyChoose banknotes from the wallet so the total is even and as large as possible, using any subset; print NIESTETY if only odd totals are reachable.Medium4GreedyMath+2No attempts yet2s512 MBJudgeable
Breaking BranchesTwo players alternately split pieces of a length n branch into integer parts; the last to move wins. Decide the winner and give Alice's winning first move.Medium4Game theoryMath+2No attempts yet1s512 MBJudgeable
Feeding SealsEach volunteer can carry one or two buckets as long as their combined weight stays within capacity c. Find the minimum number of volunteers needed to move all buckets.Medium4GreedyTwo pointers+2No attempts yet2s512 MBJudgeable
Short SellGiven N daily prices and a daily interest K per 100 borrowed coins, pick a borrow day and a repay day to maximize profit.Medium4ArrayPrefix sum+2No attempts yet1s512 MBJudgeable