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 |
|---|---|---|---|---|---|---|
| KaraokeAssign each note of a sequence to one of two singers so that the total of the absolute pitch jumps within each singer's subsequence is minimized. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Secret MissionGiven n candidates with talkativeness values, use at most s adjacent swaps to make the sum of the first k values as small as possible. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hongjun and AntimatterCount contiguous subarrays of length at least 2 that can be split into two disjoint nonempty parts with equal sums, modulo 1e9+7. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| PasswordGiven finishes over N years, find the lexicographically largest password substring allowed by rules and count its occurrences. | Medium7 | ArrayString matching+1 | No attempts yet | 4s | 256 MB | Judgeable |
| Glass BridgeGiven N and values a_i, count pairs i < j with a_i > a_j. | Medium7 | ArrayDivide and conquer+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Largest XOR sum subarrayGiven a sequence, find the maximum XOR value over all contiguous subarrays of length at least one. | Medium7 | Bit manipulationTrie+2 | No attempts yet | 10s | 512 MB | Judgeable |
| Sequence and Queries 4For each query range [l,r], find the maximum distance between two positions in the range that hold the same value. | Medium7 | ArrayPrefix sum+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Distinct values in a rangeGiven a static array and many range queries, report how many distinct values occur in each subarray. | Medium7 | ArraySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Suffix Array 3Given a permutation built by moving and reversing intervals, count the strings whose suffix array equals it, modulo 1e9+7. | Medium7 | ArrayCombinatorics+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Free WeightsTwo rows of dumbbells, each mass appearing twice, must be paired up; minimize the heaviest dumbbell that must be lifted. | Medium7 | ArrayTwo pointers+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Expect to WaitGiven a time-ordered schedule of unicycle drops and grouped requests, compute the total wait time of all requesters for each of several starting unicycle counts, or report infinity if anyone is left waiting. | Medium7 | Prefix sumBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Longest Increasing Subsequence 4Find a longest strictly increasing subsequence of A, and among all of maximum length output the lexicographically smallest one along with its length. | Medium7 | Dynamic programmingBinary search+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Restoring the longest increasing subsequenceFind the length of the longest strictly increasing subsequence of A and print the lexicographically smallest subsequence achieving that length. | Medium7 | Dynamic programmingBinary search+2 | No attempts yet | 3s | 512 MB | Judgeable |
| PyramidBuild an n-row triangular pyramid from a linear recurrence, then answer queries for the maximum value inside a downward triangular sub-pyramid. | Medium7 | Dynamic programmingArray+1 | No attempts yet | 4s | 512 MB | Judgeable |
| Happy sequenceGiven a non-happy sequence, count and list every single-element replacement that makes all adjacent absolute differences exactly the set 1..N-1. | Medium7 | ArrayHash map+1 | No attempts yet | 1.5s | 256 MB | Judgeable |
| Sorting Array (Small)Split a permutation into K contiguous blocks, sort each block, then reorder at most P=2 blocks by swapping to fully sort the array; find the largest feasible K. | Medium7 | ArraySorting+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Why Did the Cow Cross the Road 10Given two permutations of 1..N, cyclically shift one of them and minimize the number of pairs whose order differs between the two sequences. | Medium7 | ArraySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Jurisdiction DisenchantmentGiven n odd points, find the smallest axis-aligned rectangle (possibly degenerate) that contains strictly more than n/2 of them, and output its area. | Medium7 | ArraySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Wookje is a gambler!!Given the starting top faces of N signed coins in two rounds, maximize the difference between the largest reachable first-round sum and the smallest reachable second-round sum using flips of three consecutive coins (clipped at the ends). | Medium7 | MathGreedy+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Distinct values in a rangeGiven an array, answer many queries counting the number of distinct values in a subarray. | Medium7 | ArraySorting+2 | No attempts yet | 5s | 1024 MB | Judgeable |
| Distinct values and queries 2Count distinct values in subarray [l, r] for up to 10^6 queries, where each query's left endpoint depends on the previous answer. | Medium7 | SortingPrefix sum+2 | No attempts yet | 5s | 1024 MB | Judgeable |
| Maze EscapeOn a grid with walls, find the shortest path from start to exit when exactly one wall cell may be removed. | Medium7 | BFSGraph+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Collatz ConjectureCount how many distinct gcd values appear among all contiguous subarrays of the given sequence. | Medium7 | ArrayMath+1 | No attempts yet | 10s | 512 MB | Judgeable |
| Manhattan MorningsChoose a monotone shortest path from house to workplace on the Manhattan grid that passes through as many errand points as possible. | Medium7 | Dynamic programmingSorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Biotechnology laboratoryGiven a string of lowercase letters weighted 1 to 26, count how many distinct total weights occur among all non-empty substrings. | Medium7 | Prefix sumTwo pointers+2 | No attempts yet | 7s | 1024 MB | Judgeable |
| Yes, Yes, It's NonogramsRepeatedly apply line-by-line nonogram deduction until no square's color is forced, then print the resulting grid. | Medium7 | SimulationImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Intelligence in PerpendiculariaGiven an orthogonal simple polygon, find the total length of wall that an observer looking along a principal axis direction cannot see. | Medium7 | GeometryImplementation+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Robot RaceFor each of up to a million queries on an n by m grid of obstacles, decide whether a monotone path moving only right or down connects the two given empty cells. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| A New SequenceGiven a circular sequence A, compute each b_i as the sum of a_{i+k mod N} weighted by (-1)^k times (k+1) over all k from 0 to N-1. | Medium7 | MathPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Black or WhiteGiven a start row s and target row t of B/W bricks, find the minimum number of strokes, each painting at most k consecutive bricks one color, to reach t. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Reverse and RejoinSplit a fixed sequence into two non-empty parts, reverse each part, and print the lexicographically smallest result among all split positions. | Medium7 | ArrayString matching+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Paul the barista picks coffee beansPick the longest subsequence of the given row so that consecutive picked values are congruent mod k or differ by at most d in absolute value. | Medium7 | Dynamic programmingSegment tree+2 | No attempts yet | 1.5s | 64 MB | Judgeable |
| Road ConstructionGiven a permutation, for each query [l,r] reverse that segment and report the number of maximal increasing runs in the resulting array. | Medium7 | ArrayMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Heaven's Kitchen 2Given an array of integers, choose two non-overlapping nonempty contiguous subarrays and maximize the product of their sums. | Medium7 | ArrayDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Yonsei Water ParkGiven N stones in a line with values K_i, pick a starting stone and a sequence of distinct stones where each jump moves at most D positions, maximizing the sum of visited values. | Medium7 | Dynamic programmingSegment tree+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Open SesameGiven pebble and groove heights per column, choose subarray moves adding or subtracting 1 each second to align all pebbles with grooves in minimum time. | Medium7 | ArrayPrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Snow BootsFind the minimum number of boot pairs Farmer John must discard, given a stack-ordered backpack and snow-depth and step-size limits, to walk from tile 1 to tile N. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Out of SortsCount how many times the outer loop of this bubble sort implementation runs before the array becomes sorted. | Medium7 | SortingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Puyo Puyo StackingGiven a final Puyo Puyo board, print one accepted sequence of pair drops that builds it in the exact column order the statement fixes, using temporary pops to clear leftovers. | Medium7 | SimulationImplementation+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| The Final Weapon, the BowCut a circular rubber band at K of M marked notches into K arcs; maximize the shortest arc among the K pieces. | Medium7 | Binary searchGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| IncineratorMaintain a queue of waste and M incinerator cells under burn, query, append, and recycle commands, then report the final cells. | Medium7 | ImplementationQueue+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Ukje Is a Politician!!Given an odd N, a target bit t, and an N by N grid of 0/1, repeatedly set any full row or column to all 1 if it currently has a majority of 1s, else all 0; decide whether the whole grid can reach all t. | Medium7 | ArrayMatrix+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Array and OperationsApply a sequence of global 'add index to each position' updates and range reversals to a zero array, then report the values at m queried positions. | Medium7 | ArrayImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| WarGiven a permutation of worm targets, reorder humans only by moving the last to the front and find the minimum moves for a winning formation, or report -1. | Medium7 | ArraySorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Andrew's Amazing ArchitectureGiven required block lengths for n columns, choose actual heights forming a unimodal sequence that respects each requirement and minimizes total volume. | Medium7 | ArrayGreedy+2 | No attempts yet | 3s | 512 MB | Judgeable |
| The 271st Well-Known CupPick pairs so the opponent takes the one with larger B; greedily keep the largest A while holding a B gap and fallback cheaper in A. | Medium7 | GreedyHeap+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| HillsLower consecutive hills to form k peaks in n hills so that at least k hills exceed both neighbors, minimizing total height reductions, for every k from 1 to ceil(n/2). | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Zebra ArtToggle each pixel by as many rectangle and diamond updates as cover it, then print the resulting two-color image of W by H pixels. | Medium7 | MatrixArray+2 | No attempts yet | 1.5s | 512 MB | Judgeable |
| Strange Power LinesKeep a maximum subset of K lines with at most one per pole and no crossings, where pole labels are given in shuffled order. Output the number of lines to remove. | Medium7 | Dynamic programmingArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Mount MarathonGiven up to 52 piles of one card each, repeatedly move a single-card pile onto the pile just to its right if its value is at least the right pile's top card. Find the minimum final number of piles. | Medium7 | ArrayStack+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sixth SenseGiven the opponent's fixed play order and Future's multiset of cards, decide the order she plays them to win the most tricks, breaking ties with the lexicographically greatest sequence. | Medium7 | GreedySorting+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Bovine ConventionGiven N cow arrival times and M buses of capacity C, assign cows so the largest difference between a cow's arrival and its bus's departure is minimized. | Medium7 | Binary searchGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sterilizing SprayMaintain an array under point assignments and range operations that replace each value y by floor(y/K), answering range-sum queries; K is at most 10. | Medium7 | Segment treeArray+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Get to Work, Lute!Chemicals with given viscosities travel in order through M pipes; find the completion time of each chemical given minimum-clearance waits between them. | Medium7 | SimulationGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Buying Cards 3Sum, over all contiguous subarrays, of (maximum minus minimum) in the subarray. | Medium7 | StackArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| RunningOn a grid with walls, each move slides 1 to K empty cells in one of four directions; find the minimum number of moves from start to goal. | Medium7 | BFSGraph+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Castle DefensePlace 3 archers on the wall row so that the total number of enemies killed by their attacks before reaching the wall is maximized. | Medium7 | Brute forceSimulation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Fine Dust, Goodbye!Simulate T seconds of dust diffusion on a grid plus the circular wind from a two-cell air purifier, then sum the remaining dust. | Medium7 | SimulationImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Odd SubsequenceCount the distinct multisets chosen as subsequences whose element sum has an odd number of odd digits (1, 3, 5, 7, 9 in the decimal representation). | Medium7 | CombinatoricsArray+2 | No attempts yet | 3s | 512 MB | Judgeable |
| Unify the ColorsFor each button, compute the minimum presses needed to unify all colors when allowed to press only that button. Output the leftmost button with the smallest count. | Medium7 | ImplementationArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Dynamic RollerFor each tile i, count the tiles to its right whose viscosity B is at most A_i, given B is nondecreasing. | Medium7 | Binary searchArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Flag DanceMaintain an array under point updates and answer range queries for the absolute difference between sums of charismas at even and odd positions within the range. | Medium7 | Segment treePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 1.5Maintain an array under point updates and answer range queries counting how many elements in a subarray exceed k. | Medium7 | Segment treeSorting+2 | No attempts yet | 1.5s | 512 MB | Judgeable |
| Blurred PicturesEach row gives a contiguous run of good pixels [ai, bi]; find the largest axis-aligned square whose every pixel is good. | Medium7 | ArrayTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Tally CountersGiven initial and target values on n counters that wrap from m back to 1, find the minimum number of operations, where each operation pushes a contiguous block of counters once. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Killing ChaosCoaches are destroyed one by one in a given order; after each destruction, report the maximum total chaos over the whole process, where chaos sums rounded-up segment counts times the number of segments. | Medium7 | Union-findImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| A+B ProblemAdd two huge integers given as run-length encoded digit blocks and print the sum in the same compressed format. | Medium7 | ImplementationSimulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Incremental InductionGiven the tournament results of n players, choose an elimination order and find the smallest k so that at every prefix, at most k games were won by a player who is not yet inducted against one already inducted. | Medium7 | GreedyImplementation+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Card DroppingGiven the technique used for each dropped card in order, reconstruct the initial top-to-bottom ordering of cards 1..N that produces a sorted pile. | Medium7 | SimulationLinked list+2 | No attempts yet | 2s | 1024 MB | Judgeable |
| Chisam's Stepping Stone CrossingWater spreads from given sources one cell per day; find the earliest day Chisam can walk over watered stones from (1,1) to (N,N). | Medium7 | BFSBinary search+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| WinteringMaintain acorn counts on a circular walkway split into contiguous regions, supporting range additions and range sum queries over possibly wrapping cell intervals. | Medium7 | Segment treePrefix sum+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Piano PerformanceAssign each of M notes to one of N fingers spaced K apart so the largest adjacent-note difficulty is minimized; output that minimum. | Medium7 | Binary searchGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Idyllic InstagramDelete the fewest photos from a reading-order sequence so that no row of three contains photos from different trips, then print the remaining sequence in rows of three. | Medium7 | Dynamic programmingArray+1 | No attempts yet | 1s | 512 MB | Judgeable |
| SpidermanFor each skyscraper height, count how many other buildings it can jump to, where a jump from h_i to h_j is allowed only when h_i mod h_j equals K. | Medium7 | MathNumber theory+2 | No attempts yet | 2s | 512 MB | Judgeable |
| SongwriterGiven a melody A, find the lexicographically smallest B with the same up/equal/down pattern as A, bounded in [L, R], and with adjacent differences at most K. | Medium7 | GreedyImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| CalendarFind the minimum number of segment reversals that rotate an array of n elements cyclically by k positions, and output the reversals. | Medium7 | ArrayMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Adult SharkSimulate a grid of sharks that each move by fixed directional priorities, leave fading scent trails, and eat the weaker shark when they collide, until only shark 1 is left. | Medium7 | SimulationImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Matrix SumCount the submatrices of an N by M matrix whose element sum is at most x. | Medium7 | Prefix sumTwo pointers+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Longest Increasing SubsequenceGiven target LIS-ending lengths f_i, construct a permutation of 1..n whose longest increasing subsequence ending at position i has length exactly f_i. | Medium7 | GreedySorting+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Cute PandaEach panda splits its donuts between bin i and bin i+1 (cyclically); find the maximum total donuts the bins can absorb. | Medium7 | GreedyArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| PilotFor each of Q altitude limits, count subarrays of heights whose maximum is at most that limit. | Medium7 | StackSorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Table TransformationApply up to a million row, column, and cell swaps to a large grid, then output a weighted modular checksum; the operation list is generated by a linear recurrence. | Medium7 | SimulationArray+2 | No attempts yet | 4s | 512 MB | Judgeable |
| Fighting RoutineFor every window length d from 1 to n, sum the number of distinct task types over all length-d windows of the given array. | Medium7 | ArrayPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| HandshakesGiven each employee's handshake count with earlier arrivals, find the largest possible number of friends any single employee can have. | Medium7 | GreedyGraph+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Same TowersGiven up to 50 block heights summing to at most 500,000, find the maximum equal height achievable by two disjoint nonempty stacks, or report -1 if impossible. | Hard8 | Dynamic programmingArray+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Quiz ShowFor N ordered quiz questions, choose right or wrong answers to maximize score: correct answers earn coins and points, hitting M coins gives a bonus, wrong answers reset coins and cost points. | Hard8 | Dynamic programmingArray+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Choosing GuitarsN guitars sit in a circle, and each turn the mover must take one guitar from every remaining contiguous group; find the max total value the first player can secure with optimal play. | Hard8 | Dynamic programmingGame theory+2 | No attempts yet | 2s | 128 MB | Judgeable |
| N-RookGiven a grid with walls blocking line of sight and pit cells that block placement but not sight, find the maximum number of mutually non-attacking rooks. | Hard8 | GraphDFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Number BoxGiven two rows of tiles that can slide within their row preserving order, find the arrangement maximizing the sum of column-wise products. | Hard8 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Nap TimePick exactly B of N intervals arranged in a circle, maximizing sum of chosen values where the first interval of each consecutive block scores zero. | Hard8 | Dynamic programmingGreedy+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Rank SortingGiven n distinct scores, output a minimum-cost sequence of single-element move operations (cost i+j each) that sorts them in descending order. | Hard8 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Dynamic Sequence Data StructureDesign a data structure supporting range assignment, range arithmetic-progression addition, mid-sequence insertion, and range-sum queries efficiently. | Hard8 | Segment treeArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Logo MatchingGiven a permutation pattern of length n and a sequence of m distinct heights, find all starting positions where a length-n window matches the relative order pattern. | Hard8 | String matchingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Selling LandFor every grid cell (as a rectangle's bottom-right corner), find the maximum perimeter of an all-grass rectangle ending there, then output counts grouped by perimeter. | Hard8 | Dynamic programmingArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Digging for OilPlace three non-overlapping K by K squares on an M by N grid of oil estimates to maximize the total sum covered, with the grid up to 1500 by 1500. | Hard8 | Prefix sumDynamic programming+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Magic BitstringsGiven a prime p, output the lexicographically smallest non-constant magic bitstring of length p-1, where each row of the modular index matrix must equal the string or its complement. | Hard8 | Number theoryMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Intellectual PropertyGiven two code bases as raw strings, find the k longest maximal substrings of the JCN base that also occur in the TDP base, with exact positions and lengths. | Hard8 | String matchingSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Rubik's CubeGiven a scrambled Rubik's Cube as an unfolded net and a sequence of up to 1000 face rotations, output the cube state after applying all rotations. | Hard8 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Edge DetectionGiven an image as run-length encoded runs, set each output pixel to the largest absolute difference from its 8 neighbors, and emit the result as runs. | Hard8 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Stairways of SaharnaSplit a sequence into k disjoint non-decreasing subsequences to maximize the total number of chosen elements, and output this maximum for every k up to the point where all n elements are used. | Hard8 | Dynamic programmingGreedy+2 | No attempts yet | 0.2s | 128 MB | Judgeable |