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,178 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| EvakumMaintain an array with range-add updates and range-sum queries, answering the queries in the order given. | Medium5 | Prefix sumArray+2 | No attempts yet | 1.5s | 256 MB | Judgeable |
| Meditation DisturberEach bird on the left or right chirps on some seconds; remove one bird so the peak absolute value of the running signed sum over M seconds is minimized, and report its index and that value. | Medium5 | Prefix sumImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 5th Job AdvancementOrder n quests and toggle at most k active Arcane Stones to split each quest reward among run lengths, maximizing total collected experience. | Medium5 | SortingPrefix sum+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Adding 1, 2, 3 (9)Count ordered compositions of n into parts 1, 2, and 3 that use at most m terms, and output each count modulo 1,000,000,009. | Medium5 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| DSHS BankPick the branch minimizing the total taxicab distance to all others, breaking ties by smallest branch number. | Medium5 | MathSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Amusement ParkCitizens at various blocks must reach block 0 by taxi (A per block, one rider) or by sharing a bus (B won, up to 40 riders, one pick-up point). Find the minimum total cost. | Medium5 | Dynamic programmingSorting+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Seungbeom CorporationMaintain balances on a company mentor tree while updates add a value to one employee and every employee below them. | Medium5 | TreeDFS+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Area RugCount dirty cells under an s-by-s rug at every placement on an n-by-n grid, then report how many placements cover each possible count. | Medium5 | Prefix sumArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Where is the BoundaryGiven m binary strings of length n, cut the line between two prefectures and label each side east or west to minimize mismatches. Report the two prefectures meeting at the best cut, choosing the westernmost one on ties. | Medium5 | Prefix sumArray+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Value of Array BSwap at most one pair of rows or columns in an N by M grid to maximize the sum of all 2 by 2 block sums. | Medium5 | ArrayGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| OperationsMaintain a sparse integer array under point add, point reset, and range sum queries, printing the whole-array sum after each update. | Medium5 | Segment treePrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Strength ContestFor each split of a line of fighters into a left and right team, the max of each side fights; count which side wins more splits, or report a tie. | Medium5 | Prefix sumArray+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Stars Falling from the Sky: 1, 2, ..., R-L+1 of ThemMaintain an array where a range update adds 1,2,...,R-L+1 to positions L..R, and point queries ask the current total at one index. | Medium5 | Prefix sumArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| FLEXDistribute M extra ten-thousand-won units among N days to minimize the sum of squared drops between consecutive daily spends. | Medium5 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sum of DivisorsGiven N up to 10^6 and 10^5 test cases, compute g(N), the sum of the divisor sums f(y) for all y from 1 to N. | Medium5 | MathNumber theory+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Brazilian Popcorn MarathonSplit a row of popcorn bags into at most C contiguous segments, minimizing the maximum segment sum given each competitor eats at most T per second. | Medium5 | Binary searchGreedy+2 | No attempts yet | 1.5s | 512 MB | Judgeable |
| StringsBuild strings by concatenating earlier strings or slicing a substring, then output the sum of ASCII codes of the final string modulo 1e9+7, without materializing the possibly huge string. | Medium5 | Dynamic programmingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Summer TripGiven a string of event types, count contiguous substrings of length at least two whose first and last characters are distinct and each appears only once in the substring. | Medium5 | StringTwo pointers+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| Find my FamilyFor each photo, decide whether some arrangement lets Alice (taller than you) stand left of you and Bob (taller than both) stand right of you. | Medium5 | ArrayPrefix sum+2 | No attempts yet | 7s | 512 MB | Judgeable |
| SnowballSnowballs form at each altitude with size 1 and multiply by x each centimeter they descend; find the total size of all snowballs modulo 1e9+7. | Medium5 | MathPrefix sum+2 | No attempts yet | 0.5s | 256 MB | Judgeable |
| Balanced AnimalsFind the smallest integer threshold t that splits the animals by weight into two groups of equal total weight, handling ties at t by pairing them off. | Medium5 | SortingPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| BNKQFrom a day of bank teller queue records, find each teller's processed-customer count and busiest one-hour window, then report the top three tellers. | Medium5 | Hash mapSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Stacking Blocks TogetherEach of N students offers a set of distinct block sizes, at most one block per student is used, and we count subsets of students whose chosen blocks sum to exactly H modulo 10007. | Medium5 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |
| A Really Odd SequenceGiven a sequence of integers, find the maximum sum of a contiguous subarray whose length is odd. | Medium5 | ArrayDynamic programming+2 | No attempts yet | 6s | 512 MB | Judgeable |
| MountainsCount triples x < y < z where the middle mountain y is strictly taller than both mountain x and mountain z. | Medium5 | ArrayCombinatorics+2 | No attempts yet | 2s | 256 MB | Judgeable |
| MerlinGiven n vessels with amounts of elixir, find the minimum number of vessels to empty (and smash) so the remaining vessels can be made equal by redistributing the poured elixir. | Medium5 | GreedyMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Finding a Sequence from a Sign MatrixGiven the sign pattern of all subarray sums of a hidden integer sequence, reconstruct one integer sequence (values -10 to 10) that produces the same sign matrix. | Medium6 | Prefix sumMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Tree PlantingPlant trees in order and compute the product, modulo 1e9+7, of the sum of distances from each new tree to all previously planted trees. | Medium6 | Segment treePrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| SoldiersMaintain unit sizes under point updates and answer queries for which unit contains a given soldier serial number using prefix sums. | Medium6 | Segment treeBinary search+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Artist Lee DonghoGiven a black/white grid and a limit on horizontal single-color brush strokes, find the minimum number of cells that end up unpainted or wrongly colored. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Morning Three and Evening FourGiven N banana weights, choose non-overlapping length-K blocks to move as a C-second group, minimizing total time and then the number of groups used, with output of chosen block positions. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Sequences of 1 and -1Given M sequences of 1 and -1 of even length N, construct for each one a partner sequence whose elementwise product sums to zero, using at most N distinct partner sequences overall. | Medium6 | CombinatoricsPrefix sum+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Maximum Submatrix SumGiven an N by M integer matrix, find the maximum possible sum over all contiguous rectangular submatrices. | Medium6 | Dynamic programmingMatrix+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Run, RunFind the maximum distance covered in N minutes of running and forced resting under a fatigue cap M, using dynamic programming over run-rest blocks. | Medium6 | Dynamic programmingPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Choosing a Subarray 2Find a contiguous subarray maximizing (sum of elements) times (minimum element), and output that maximum score with the interval bounds. | Medium6 | StackPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Choosing a SubarrayGiven an array, find the contiguous subarray that maximizes the product of its sum and its minimum element. | Medium6 | StackPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Two TowersGiven segment lengths of a cycle of N points, find two points maximizing the shorter of the two circular path distances between them. | Medium6 | Binary searchPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Butcher ShopGiven N meat pieces with weight and price, find the minimum cost so that buying one piece and receiving all strictly cheaper pieces free reaches a target total weight M. | Medium6 | SortingPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Cutting IntervalsGiven N intervals, find cut points A and B minimizing A then B so the total overlapped length inside [A,B] equals exactly K, or output 0 0. | Medium6 | Binary searchPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| LieDetect the first parity query in a sequence that becomes inconsistent with earlier ones, using weighted union-find over prefix-sum parities. | Medium6 | Union-findBit manipulation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Small LocomotivesChoose three disjoint consecutive-car segments (each up to a fixed length) from a train to maximize total passengers carried. | Medium6 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Pizza SalesGiven two circular arrays of pizza-slice sizes, count ways to pick a contiguous arc from one pizza, from the other, or one arc from each, summing exactly to K. | Medium6 | Prefix sumHash map+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Car Race MaintenanceGiven a maximum travel range and per-station maintenance times, select a minimum-cost subset of stations so consecutive gaps never exceed the range, and output the chosen stations. | Medium6 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Sanggeun's RobotTrack a moving point's total Manhattan distance to many fixed checkpoints after each move, requiring separate sorted-prefix-sum structures for x and y coordinates updated dynamically. | Medium6 | Prefix sumBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Salary Management at a Car FactoryGiven a company tree with salary updates that add a value to all subordinates of a node and queries for a single employee's current salary, answer efficiently using an Euler tour and a range-update point-query structure. | Medium6 | TreePrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Beautiful MatrixGiven an N x N matrix (N up to 400), find the maximum difference between the main diagonal sum and anti-diagonal sum over all possible square submatrices. | Medium6 | MatrixPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Water TaxiGiven pickup and drop-off points along a line for many passengers picked up by a boat starting at 0 that must end at M, compute the minimum travel distance covering everyone. | Medium6 | GreedyPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Interesting SequenceFor each starting index, find the maximum even-length window whose first half sum and second half sum are both at most S, using binary search and prefix sums. | Medium6 | Binary searchPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Pretty IndentationGiven current and target tab counts per line, find the minimum number of range increment/decrement operations to transform one array into the other, with the constraint that decrements can't push a value below zero. | Medium6 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ProgramSimulate marking multiples of several jump values into an array using a difference/counting trick, then answer many range-sum queries with prefix sums. | Medium6 | Prefix sumArray+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Snow White and the DwarfsGiven a sequence of hat colors and range queries, determine for each range whether a majority color exists and identify it. | Medium6 | Binary searchPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Arranging BlocksGiven M unit blocks stacked on cells of an N by N board, find the minimum moves to rearrange them into a rectangle with exactly one block per cell. | Medium6 | Prefix sumBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Analog DialSimulate M range-sum queries followed by range +1-with-wraparound-to-0 updates on N digit dials, using a data structure that supports both efficiently. | Medium6 | Segment treePrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| ConfusionCount permutations of 1..N with exactly C inversions, modulo 1e9+7, using DP with prefix sums for the given constraints. | Medium6 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Camouflaged CampUsing prefix sums over the grid, find the L x W camp position that satisfies the most given adjacent-area altitude comparison rules, breaking ties by smallest row then column. | Medium6 | Prefix sumSliding window+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Lineland's AirportFind the position of a length-L window along a piecewise-linear terrain profile that minimizes the area above the flat strip that must be excavated. | Medium6 | GeometryBinary search+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Tanks a LotGiven gas stations on a circular track whose fuel exactly covers one lap, list every station and direction from which a full lap can be completed. | Medium6 | Prefix sumGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Data RecoveryGiven a grid with some unknown cells plus all row and column sums, print each unknown cell's forced value, or -1 if several values fit. | Medium6 | GraphPrefix sum+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Security CompanyPoints lie on a line with travel times between neighbors; starting from point a and visiting every point, minimize the total first-arrival time over all points. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Semi-prime H-numbersFor each H-number h, count H-semi-primes up to h, where H-primes are irreducible among numbers of the form 4n+1. | Medium6 | Number theoryMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bulletin BoardGiven up to 100 axis-aligned rectangles on a board, report the uncovered area, the maximum overlap depth, and the area covered at exactly that depth. | Medium6 | GeometrySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Raggedy, RaggedyGiven word widths and a max line length, split the words into lines and minimize the sum of squared unused space on every line except the last. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Think I'll Buy Me a Football TeamGiven a matrix of inter-bank debts, compute the total cash needed to settle all debts and the minimum possible after netting and rerouting payments. | Medium6 | ArrayGraph+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Chop Ahoy! Revisited!Count the ways to split a digit string into consecutive groups whose digit sums are non-decreasing across groups. | Medium6 | Dynamic programmingPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| Complaint SortGiven a sequence of n values, count the strictly decreasing subsequence triples (i < j < k with a_i > a_j > a_k). | Medium6 | ArrayCombinatorics+2 | No attempts yet | 1s | 256 MB | Judgeable |
| MicrospikesGiven interleaved per-appliance power change records with relative times, reconstruct the total power timeline and count maximal above-threshold intervals of duration 1 to S that start and end. | Medium6 | SimulationSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Digit Sum of a RangeFor each query [a,b] with b up to 10^15, output the sum of all decimal digits of every integer in the range. | Medium6 | MathDynamic programming+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Dividing the LootGiven N item values and P other pirates, choose a set of items for yourself so no other pirate gets more items than you, maximizing your total value. | Medium6 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RaisinsSplit an N by M chocolate bar into unit cells by straight cuts; each cut costs the raisins in the piece, and the goal is to minimize the total payment. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 3s | 128 MB | Judgeable |
| King Jaguar's PyramidPlace an a by b pyramid and an interior c by d chamber on a grid to maximize the sum of base squares minus chamber squares. | Medium6 | Prefix sumBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Drawing with XOREach XOR call flips a rectangle anchored at the bottom right, so the number of calls equals the count of pixels that differ from the pixel below and the pixel to the right, plus the bottom-right pixel. | Medium6 | ArrayMatrix+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Batch SchedulingSplit the ordered jobs into consecutive batches, each paying a setup time, and minimize the sum of weighted completion times. | Medium6 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Light Bulb DecorationGiven a binary string, flip at most one contiguous range so that some contiguous alternating substring becomes as long as possible, and report that length. | Medium6 | ArrayPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Card Game is FunAnna may delete arbitrary cards from her sequence and Bruno may trim cards from the top and bottom of his; find the longest common subarray obtainable. | Medium6 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| The Used BookstoreChoose exactly K of N books to sell, maxing the total where selling t books of one genre adds t(t-1) extra to that genre's group. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Splitting the SnackChoose which of the N-1 cut points to cut so that both people get exactly N/2 pieces, minimizing the total force of the chosen cuts. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Ants ColonyBuild a weighted tree where each new node attaches to an earlier one, then answer distance queries between pairs of nodes. | Medium6 | TreeDFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Finding SeatsGiven an R by C grid of free and taken seats, place K people on free seats so the bounding rectangle has the smallest area. | Medium6 | Two pointersBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Painting the FenceBessie walks along a number line and each segment she covers gains a coat of paint; find the total length covered by at least K coats. | Medium6 | IntervalsSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Painting the FenceBessie walks back and forth along a line, each pass adding a coat; find the total length covered by at least two coats. | Medium6 | Prefix sumSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Balanced Cow BreedsCount the ways to 2-color the parentheses in a string so that each color class, read in order, forms a balanced parenthesis sequence. | Medium6 | Dynamic programmingString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Nearby CowsOn a tree of N fields with C(i) cows at each field, report for every field the total cows within distance K, where K is at most 20. | Medium6 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Umbrellas for CowsGiven cow positions on a line and a price for each umbrella width, find the cheapest set of umbrellas that covers every cow, allowing overlaps. | Medium6 | Dynamic programmingSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Above the MedianGiven N cow heights, count contiguous ranges whose defined median (the ceil(K/2)-th smallest) is at least a threshold X. | Medium6 | Prefix sumBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Mowing the LawnGiven N cows in a row with efficiencies, pick a subset that never includes more than K adjacent cows and maximize the total efficiency. | Medium6 | Dynamic programmingSliding window+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Great Cow GatheringPick a node of a weighted tree with node weights as the gathering point, and minimize the sum of cow count times distance to that node. | Medium6 | TreeDFS+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Secret MessageGiven M binary messages and N binary codewords, count for each codeword how many messages share a prefix relation with it in either direction. | Medium6 | TrieString+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bulls and CowsCount binary sequences of length N where every pair of bulls has at least K cows between them, modulo 5000011. | Medium6 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 128 MB | Judgeable |
| CakePartition the sequence of slice lengths into consecutive blocks, bottom to top, so each block's sum is at least the one above, and maximize the number of blocks. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| River CrossingSplit N cows into consecutive groups, each crossing costs M plus the cumulative marginal cost, and add M for every return trip; minimize the total time. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Balanced LineupGiven N cow heights and Q ranges, report the difference between the maximum and minimum height within each query range. | Medium6 | Segment treeArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Face the Right WayChoose a fixed block size K so that flipping blocks of K consecutive cows turns the whole row forward using the fewest operations, breaking ties by smallest K. | Medium6 | GreedySimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| KingGiven weighted inequalities on subarray sums, decide whether some integer sequence satisfies all the bounds; output which phrase tells the answer. | Medium6 | GraphShortest path+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Annoying Painting ToolGiven a target black-and-white grid and a fixed r by c flip rectangle, find the minimum number of flips to reach it, or report impossibility. | Medium6 | GreedySimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Halloween treatsFind the leftmost-shortest consecutive block of neighbours whose sweet total is divisible by c, or report that none exists. | Medium6 | Prefix sumHash map+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Bound FoundFor multiple targets, find the contiguous subarray whose absolute sum is closest to the target, reporting that absolute sum. | Medium6 | Prefix sumSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Bowling for NumbersGiven a row of valued pins, pick up to k non-overlapping blocks of exactly w consecutive pins to maximize the total score. | Medium6 | Dynamic programmingPrefix sum | No attempts yet | 1s | 128 MB | Judgeable |
| Primed SubsequencesFind the shortest contiguous subsequence of length at least 2 whose sum is prime, printing the leftmost one if ties exist. | Medium6 | Prefix sumNumber theory+2 | No attempts yet | 5s | 256 MB | Judgeable |
| FlattenDistribute chips between neighboring piles at a cost equal to the chips moved, and find the minimum total transferred to make all piles equal. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Dividing the PathPartition the segment [0, L] into consecutive pieces of even length between 2A and 2B so no cut lands strictly inside any cow's interval, and minimize the number of pieces, or report that no partition exists. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |