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 results1,800 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Meeting Room Scheduling 3Choose non-overlapping meetings, where each meeting's time overlaps only its immediate neighbors in the input order, to maximize the total attendee count. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 256 MB | Judgeable |
| The Last BattleA permutation a is fixed; rotating the identity arrangement right by k positions must satisfy a[i] != shifted value at each position. Find the smallest valid k, or -1. | Medium6 | ArrayMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| RobotGiven a sequence of signed step sizes, flip at most k signs to maximize the absolute value of the final position. | Medium6 | GreedySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence TransformationGiven a sequence of non-negative integers, find the minimum number of single increments needed so that 1,2,...,h appear consecutively as a block, or report that it is impossible. | Medium6 | ArraySliding window+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Minimal ProductGenerate a pseudorandom array and find indices i<j with a_i<a_j minimizing the product a_i*a_j, or report IMPOSSIBLE. | Medium6 | ImplementationGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Currency ExchangeGiven n tablet values and an integer rate p, find two distinct indices i and j so that the ratio c_i / c_j is as close to p as possible. | Medium6 | ArrayBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Stock King DonghoGiven prices for C stocks over D days and starting cash M, find the maximum cash obtainable by buying and selling whole shares each day using knapsack-style dynamic programming. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Bubble SortGiven an array, compute how many bubble sort passes occur before no swaps happen, without simulating the O(N^2) sort directly for N up to 500,000. | Medium7 | SortingSegment tree+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Dial LockGiven a current dial state and a password of N digits, find the minimum number of operations, each rotating a contiguous block of at most three circular dials by 1 to 3 steps, to reach the password. | Medium7 | Dynamic programmingMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| DNA ScoreGiven N equal-length DNA strings, design a symmetric, zero-sum score matrix with bounded entries to maximize the average pairwise alignment score. | Medium7 | GreedyMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Deque SortGiven N integers in input order, assign each to a deque (front, back, or new deque) to minimize the number of deques whose concatenation can be sorted nondecreasing. | Medium7 | GreedyBinary search+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Constructing a PermutationConstruct the lexicographically smallest and largest permutations of length N whose longest increasing and decreasing subsequences have exact given lengths M and K. | Medium7 | CombinatoricsGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Farmland LevelingGiven N heights forming a 1D terrain, find the minimum number of unit cells to remove so that the number of resulting peaks is at most K. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| RainfallGiven partial yearly rainfall records, decide for each query whether a claimed record-rain statement between two years is definitely true, possibly true, or impossible. | Medium7 | Binary searchArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Collecting GemsGiven N gem values, find a contiguous subarray of length at least M that maximizes floor(1000*sum/length), using binary search on the average. | Medium7 | Binary searchPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Building a TournamentGiven a sequence of distinct ranks, build a bracket by repeatedly merging adjacent intervals (like matches in a tournament) minimizing the total sum of absolute rank differences over all merges. | Medium7 | Dynamic programmingDivide and conquer+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Weakness in an Encryption AlgorithmGiven a sequence, decide if four indices p<q<r<s exist forming a specific interleaved value pattern, requiring an efficient algorithm beyond brute force for n up to 5000. | Medium7 | Binary searchArray+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Turning Off StreetlightsFind the optimal order to switch off all streetlights on a line, starting from a given position, minimizing sum of power times shutoff time, a classic interval DP problem. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Mischievous FrogsGiven how many frogs stepped on each of N field positions, reconstruct the minimum number of frogs, each following an arithmetic-progression path with step size at most 6, that reproduces the counts. | Medium7 | GreedySimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Descending-Run SortingGiven a permutation whose minimal slope decomposition always has even-length decreasing runs, simulate/derive how many reversal operations the described repeated slope-reversal sort performs until the array is sorted. | Medium7 | ArraySimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Walking TrailFor up to 100,000 rectangle queries over 300,000 points, count how many points lie exactly on the boundary of each axis-aligned rectangle. | Medium7 | Prefix sumBinary search+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Median of a Contiguous SubsequenceCount odd-length contiguous subarrays of a permutation of 1..N whose median equals a given value B. | Medium7 | Prefix sumHash map+1 | No attempts yet | 1s | 128 MB | Judgeable |
| HousewarmingGiven a grid with blocked cells, find the maximum rectangle of empty cells and output twice its width plus height (the perimeter). | Medium7 | Dynamic programmingStack+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Minimize the DifferenceGiven an array with a budget of T total decrements (each element bounded below by 1), reduce elements to minimize the maximum adjacent absolute difference and output the resulting array. | Medium7 | Binary searchGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| HighwayGiven a road profile and costs for flat, sloped, tunnel or viaduct travel, find the minimum time to cross using at most K equal-height shortcut structures. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Non-boring SequencesDetermine whether every contiguous subarray of a sequence has at least one element unique within that subarray, using an efficient divide and conquer approach. | Medium7 | Divide and conquerArray+1 | No attempts yet | 5s | 128 MB | Judgeable |
| Unique Encryption KeysFor each of up to a million range queries over a sequence of keys, decide if the range has a duplicate and report the smallest repeated key value. | Medium7 | Segment treeBinary search+2 | No attempts yet | 2s | 128 MB | Judgeable |
| I-KeyboardPartition an ordered list of letter frequencies into K consecutive groups to minimize sum of frequency times in-group position, with a tie-break favoring later keys getting more letters, then output the resulting keyboard layout. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| AlibabaGiven points on a line with deadlines, find the minimum finishing time to visit all points starting from an optimally chosen point, respecting each point's deadline, or report impossibility. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Non-monotonicityGiven a permutation of 1 to n, find the longest subsequence whose elements alternate down, up, down, starting with a decrease. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 10s | 128 MB | Judgeable |
| CrabblesGiven a dictionary and hands of at most 10 lettered tiles with values, find the maximum-scoring dictionary word formable from each hand's tiles. | Medium7 | TrieBacktracking+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 'Roid RageGiven up to 10 simple polygons with integer vertices, report every pair that overlaps or touches, listing pairs in sorted order. | Medium7 | GeometryImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Jumping BeansTrack how beans in a row are rearranged after T seconds of a wrap-around swapping process, printing the final order for each test case. | Medium7 | SimulationMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cookie SelectionProcess a stream of cookie insertions and median requests; each request outputs the upper median of the currently held multiset, supporting up to 600,000 operations. | Medium7 | HeapImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Team DessertDesserts sit in a row; two alternating teams take from either end, and the first-picking team wants the smallest total weight it can guarantee against optimal play. | Medium7 | Dynamic programmingGame theory+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Extreme Tic-Tac-ToeRead N-dimensional 3^N-cell tic-tac-toe boards (N up to 10) and count straight lines of three identical X or O symbols, ignoring lines with empty cells. | Medium7 | ImplementationBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Segment PricingChoose a non-increasing fare for each boarding stop, with riders boarding only if their budget covers it, to maximize total revenue. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SortingGiven a permutation, find all gap sizes X for which repeatedly scanning and swapping positions i and i+X until a pass makes no swap leaves the array sorted. | Medium7 | SortingArray+2 | No attempts yet | 0.3s | 64 MB | Judgeable |
| Top 2000Partition a fixed sequence of singles into contiguous blocks, letting each block run under or over M minutes with per-minute penalties, and minimize the total penalty. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| NailsGiven up to 500000 upward triangles on a triangular grid of N nails per side, count the nails covered by at least one triangle. | Medium7 | ArrayPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Candy Picking ContestChoose boxes in an M by N grid so no two chosen boxes touch vertically or horizontally, maximizing the total candies collected. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Shrinking Inscribed PolygonGiven arc lengths around an inscribed polygon, find the minimum number of vertices to delete so the remaining vertices form a regular polygon, or report -1. | Medium7 | Number theoryMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Turkish RoulettePlace B ordered balls into B non-overlapping pairs of adjacent wheel slots to maximize the dealer's profit, where each ball's value is its number times the sum of its two slots. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 3s | 128 MB | Judgeable |
| Help-or-elseChoose an ordered subset of people to help; the finish time of each helper accumulates, and unhelped people add a penalty, so find the largest feasible subset under budget K. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Suffering DwarvesMaintain a permutation under swaps and answer whether the set of heights A through B occupies consecutive positions. | Medium7 | Segment treeArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Fuel EconomyFind the cheapest way to buy fuel along a route with a tank of capacity G, visiting stations with given prices, or report that the trip is impossible. | Medium7 | GreedyStack+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Poker HandsGiven card counts per rank, find the fewest contiguous-rank straights whose unit cards sum to exactly those counts. | Medium7 | GreedyArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| SeatingTrack seats in a row under arrivals needing the lowest block of p empty seats and range departures; count the parties turned away. | Medium7 | Segment treeBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Running LapsCount how many times a faster cow overtakes a slower cow, counting ordered pairs, before the fastest cow finishes L laps on a track of length C. | Medium7 | SortingMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Haybale RestackingGiven N piles in a circle with current and target amounts of hay, move bales at cost equal to circular distance to reach the target with minimum total work. | Medium7 | GreedyPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cow PhotographsGiven a permutation of 1 to N, find the fewest adjacent swaps to reach a rotation of 1..N starting at some cow s, minimized over all s. | Medium7 | ArraySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BobsleddingBessie's speed changes by at most 1 per meter, turn i caps her speed at S_i when she passes marker T_i, and we want the highest speed she can reach anywhere on the course. | Medium7 | GreedyImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The LeprechaunGiven an N x N matrix on a torus, find the contiguous circular run along any row, column, or either diagonal with the largest sum. | Medium7 | ArrayDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Rooftop Garden BenchmarkingCount, over every building, how many strictly shorter buildings stand to its right before a building at least as tall blocks the view. | Medium7 | StackArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Gold Balanced LineupGiven N cows each with a K-bit feature ID, find the longest contiguous range where every one of the K features appears the same number of times. | Medium7 | Hash mapPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| To the MaxFind the contiguous rectangular subregion of an N by N integer matrix with the largest possible sum and print that sum. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Safe GamblingOn an odd circular wheel of N = 2K+1 priced pockets, choose three arcs of K consecutive pockets covering every pocket, minimizing the total sum of the arcs. | Medium7 | ArraySliding window+2 | No attempts yet | 1s | 128 MB | Judgeable |
| A Fair JuryPick exactly m candidates from a pool, minimizing |total defense minus total prosecution|, then maximizing the combined total among those juries. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Biggest (Zero Carbon) FootprintGiven tree points in an n by m forest, find the largest axis-aligned rectangle with no tree strictly in its interior. | Medium7 | GeometrySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| FirehosePlace k hydrants on a circle of circumference 1000000 so the largest arc-distance from any of H houses to its nearest hydrant is minimized, and report that distance. | Medium7 | Binary searchGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| WowowMaintain a dynamic set of (id, rating) friends under insertions, rating updates, and queries for the id holding the K-th highest rating. | Medium7 | Segment treeBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| ParadeMaintain a list of N perimeter-rotation commands on a 4x4 grid under Q cumulative point updates, printing the resulting grid after each update. | Medium7 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bowling for Numbers++Choose at most k windows of length w, possibly overlapping beyond the row ends, so the sum of the covered pins is as large as possible. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Shopping OffersGiven regular item prices and bundle offers, find the minimum cost to buy exactly the listed quantities without buying extras. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| ProcessesGiven N queues of tasks, a limited number K of process splits, and one task completed per process per second, find the minimum time to finish all tasks. | Medium7 | Binary searchGreedy+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Illusive ChaseGiven a grid with obstacles and a log of chase trips, each recorded as a range of steps in one direction, count the possible starting cells consistent with the whole sequence. | Medium7 | ArrayBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Longest Common Increasing SubsequenceGiven two integer sequences, find the length of the longest common increasing subsequence of both. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 1s | 256 MB | Judgeable |
| CollisionsIdentical balls on a line move at constant velocities and swap velocities on elastic collision; count total collisions, or report infinity if unbounded. | Medium7 | SortingMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| WatchingChoose the smallest w so that P intervals of length w and Q intervals of length 2w together cover all given event sections. | Medium7 | GreedyBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Connectivity of a Permutation GraphRead a permutation of up to one million elements and report the connected components of the graph joining i and j whenever i < j and a_i > a_j. | Medium7 | StackGreedy+2 | No attempts yet | 2s | 256 MB | Judgeable |
| RailwaysProcess train seat requests in order; accept a request only if every section it covers has enough free seats, and report T or N for each. | Medium7 | Segment treeArray+2 | No attempts yet | 3s | 128 MB | Judgeable |
| MonotonicityFind the longest subsequence of a sequence whose adjacent comparison symbols repeat a given pattern of <, >, = of length k. | Medium7 | Dynamic programmingBinary search+2 | No attempts yet | 3s | 512 MB | Judgeable |
| ShiftGiven a permutation of 1 to n, decide whether it can be sorted using only two moves: bring the last element to the front, or bring the third element to the front. | Medium7 | ArrayImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Rearranging LettersGiven two equal-length anagrams, count the minimum adjacent swaps needed to turn the first string into the second. | Medium7 | GreedySorting+1 | No attempts yet | 3s | 128 MB | Judgeable |
| BanjoPick two separate one-minute intervals to maximize the number of people present for at least one full minute. | Medium7 | ArraySorting+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Bytie's DisplayReorder the digits of a seven-segment display and flip at most n segments so the result reads as the lexicographically largest l-digit number. | Medium7 | GreedyDynamic programming+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Variable SubsequencesCount distinct nonempty subsequences, identified by position sets, in which every two consecutive terms differ. | Medium7 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 512 MB | Judgeable |
| PawnGiven a large board colored by row intervals, answer whether two squares lie in the same connected same-color region under 8-directional moves. | Medium7 | Union-findIntervals+2 | No attempts yet | 1s | 192 MB | Judgeable |
| Circular GameOn a circular board, white and black pieces slide over empty runs; decide with optimal play which side wins or whether play can go on forever. | Medium7 | Game theoryArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BusesGiven bus timetables at every stop, pick an outbound bus and an inbound bus to minimize John's total waiting time before his friend arrives, returning by the friend's arrival time. | Medium7 | SortingBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Ball Boxesn boxes in a row hold equal red and green balls with two adjacent empties; repeatedly move two balls into those empties and output a sequence that groups all reds before all greens. | Medium7 | GreedySimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Physical EducationJasio can skip up to k duels where he is the left student; find the leftmost final position he can reach. | Medium7 | ArrayDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Land SwindleFor each meadow square choose at most one rectangle ending there, maximize the total perimeter, where each rectangle must contain only meadow squares. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| VacationChoose vacation days from a 3n-day forecast, taking at most k days in every window of n consecutive days, to maximize the total temperature. | Medium7 | Dynamic programmingSliding window+2 | No attempts yet | 1s | 128 MB | Judgeable |
| TowerPartition the sequence of brick widths into consecutive blocks so that block sums do not increase from bottom to top, maximizing the number of blocks. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sunset Views 2For each point on an n by n grid, take the maximum building height within Manhattan distance k, then sum all these maxima. | Medium7 | ArrayPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| LinkNetGiven intervals on a line, schedule each transmission into a tick so that no interval in the same tick contains another interval's endpoint strictly inside it, and no point is used twice per tick; find the minimum ticks. | Medium7 | IntervalsGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Cake PieceFind the k-th largest piece area after cutting a rectangle with n cuts in each direction. | Medium7 | Binary searchSorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| BytecomputerRepeatedly add an entry to its right neighbor in a -1, 0, 1 sequence to make it non-decreasing with the fewest operations, or report BRAK if impossible. | Medium7 | Dynamic programmingArray | No attempts yet | 3s | 512 MB | Judgeable |
| Golf BotCount how many hole distances equal one dial distance or the sum of two dial distances. | Medium7 | Divide and conquerMath+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Rotating the KeyringCount all wrong key tries made while doors 1 to N are unlocked in cyclic order K times with a rotating keyring. | Medium7 | ArrayMath+1 | No attempts yet | 1s | 64 MB | Judgeable |
| Unique right triangleCount the perimeters up to N that form exactly one integer-sided right triangle. | Medium7 | Number theoryArray+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Spam FilterFind the contiguous block of at least k binary results with the highest share of ones, breaking ties by earliest start then shortest length. | Medium7 | Binary searchPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| ShufflesGiven a permutation of 1 to n, find the fewest riffle shuffles that can turn the sorted deck into it. | Medium7 | MathArray | No attempts yet | 2s | 256 MB | Judgeable |
| Shortest Complete SubarrayProcess point updates on an array and report the length of the shortest contiguous subarray containing every value from 1 to K, or -1 if none exists. | Medium7 | Segment treeSliding window+1 | No attempts yet | 3s | 512 MB | Judgeable |
| What Are Birds? (Large)Given labeled points and the fact that birds are exactly the points in a height interval crossed with a weight interval, classify each query as always bird, never bird, or unknown. | Medium7 | ArrayIntervals+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Gregory and the BankGiven fixed incoming and outgoing amounts plus a schedule of receiving and sending days, assign each transfer to a day to maximize suppliers paid. | Medium7 | GreedySorting+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Train in a TunnelGiven car lengths and light states, find the minimum number of extra lights to turn on so that at every moment some lit car overlaps the tunnel. | Medium7 | ArrayTwo pointers+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Problem PreparationMaintain an array under point increments and decrements, and after each update answer the sum of ceil(t_i / k) for a given k. | Medium7 | MathPrefix sum+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Range XORMaintain an array under range xor updates and range xor queries, both on subarrays given by index bounds. | Medium7 | Bit manipulationSegment tree+2 | No attempts yet | 2s | 512 MB | Judgeable |