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 results388 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
Minimum valueAnswer up to 100,000 range minimum queries over a static array of up to 100,000 integers.Easy3Segment treeNo attempts yet1s256 MBJudgeable
BeadsProcess point additions to boxes and answer range-sum queries in order for each game.Easy3Segment treeNo attempts yet1s256 MBJudgeable
Sequence and Queries 37Maintain an array under point updates, and for range queries report how many entries are even or odd.Easy3ArrayPrefix sum+2No attempts yet1s512 MBJudgeable
Coffee Shop Game 2Given an array, answer Q online queries each asking a range sum (with swapped bounds allowed) followed by a point update.Medium4Segment treePrefix sum+1No attempts yet2s256 MBJudgeable
Range Sum Query with UpdatesSupport point updates and range-sum queries on an array of up to a million integers using a Fenwick tree or segment tree.Medium4Segment treeArray+1No attempts yet2s256 MBJudgeable
Sum of Numbers 7Support point updates and range sum queries on an array of up to 1,000,000 elements over up to 1,000,000 operations, requiring a Fenwick tree or segment tree.Medium4Segment treePrefix sum+1No attempts yet2s256 MBJudgeable
Minimum and MaximumGiven N numbers and M range queries, output the minimum and maximum value within each query's index range.Medium4Segment treeArrayNo attempts yet2s192 MBJudgeable
CannonsFor each query, report the minimum and maximum value in the given subarray of cannon strengths.Medium4Segment treeArrayNo attempts yet1s128 MBJudgeable
Digital Video Discs (DVDs)The program tracks disc swaps on numbered slots and reports whether slots A to B hold exactly discs A to B.Medium4Segment treeNo attempts yet2s256 MBJudgeable
Algorithms Final ExamGiven the final order listed by midterm rank, print for each student how many midterm superiors they passed minus how many inferiors passed them.Medium4Segment treePrefix sumNo attempts yet1s256 MBJudgeable
Range Add and Range SumProcess range additions on a sequence and print the sum of each queried range in order.Medium4Segment treeNo attempts yet2s256 MBJudgeable
Range product queriesAnswer range product queries modulo 1,000,000,007 on a sequence with point updates.Medium4Segment treeNo attempts yet1s256 MBJudgeable
Table Range Sum with UpdatesApply point updates on an N by N table and answer each rectangle sum query in order.Medium4Segment treeNo attempts yet1s256 MBJudgeable
TradingEach trader covers villages L to R with a price that rises by 1 per village, and each village reports the highest price ever asked there.Medium4Segment treeIntervalsNo attempts yet2s64 MBJudgeable
Counting HaybalesApply range additions to N fields and answer Q range-minimum and range-sum queries in order.Medium4Segment treeNo attempts yet2s512 MBJudgeable
SwitchesGiven a switch array of size N, support range flips and range count-of-on queries over M operations, best solved with a segment tree with lazy propagation.Medium5Segment treeIntervals+1No attempts yet1s128 MBJudgeable
Drunk CodingMaintain a sequence under point updates and answer range-product sign queries (+/-/0) for each test case until EOF.Medium5Segment treePrefix sum+2No attempts yet1s256 MBJudgeable
Switching LightsMaintain a binary array of N lights under M range-toggle and range-count operations, and print each query result.Medium5Segment treeArray+1No attempts yet1s128 MBJudgeable
Balanced LineupGiven a static array of cow heights, answer queries giving the max minus min over each range [A, B].Medium5Segment treeArrayNo attempts yet1s128 MBJudgeable
Two WordsAfter each swap of one character between the two strings, report which string is lexicographically larger.Medium5Segment treeStringNo attempts yet1s512 MBJudgeable
Reconstruct the QueueGiven each arrival's insertion spot in a growing queue, compute every person's final position at dispersal.Medium5Segment treeNo attempts yet1s128 MBJudgeable
RankingsPlayers accumulate points through updates and each query asks for the current rank of one player among up to 100000 players.Medium5Segment treeSorting+1No attempts yet3s128 MBJudgeable
Incomparable rectangle pairsCount the pairs of rectangles where neither fits inside the other after translation or a 90-degree rotation.Medium5SortingGeometry+1No attempts yet2s512 MBJudgeable
Salary InequitySubtree raises add an amount to every salary below an employee, and each query asks for the max minus min salary in that subtree.Medium5Segment treeTreeNo attempts yet10s256 MBJudgeable
Lunch MenuCount the menus whose spiciness falls in [u, v] and whose sweetness falls in [x, y] for each query.Medium5Segment treeSorting+1No attempts yet1s512 MBJudgeable
Sequence and Queries 15Maintain an array under point updates and, after each change, report the smallest index holding the minimum value.Medium5Segment treeImplementationNo attempts yet1s512 MBJudgeable
OperationsMaintain a sparse integer array under point add, point reset, and range sum queries, printing the whole-array sum after each update.Medium5Segment treePrefix sum+2No attempts yet2s512 MBJudgeable
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.Medium6Segment treePrefix sum+1No attempts yet2s128 MBJudgeable
SoldiersMaintain unit sizes under point updates and answer queries for which unit contains a given soldier serial number using prefix sums.Medium6Segment treeBinary search+2No attempts yet1s256 MBJudgeable
Permutation RestorationGiven the inversion sequence of a permutation of 1..N, reconstruct the original permutation using an efficient data structure.Medium6Segment treeBinary search+2No attempts yet0.55s128 MBJudgeable
Bubble SortGiven an array, find the value of loop counter i when an early-exit bubble sort finishes sorting it.Medium6SortingArray+2No attempts yet2s128 MBJudgeable
PermutationReconstruct a permutation of 1..N from A[i], the count of larger elements appearing before i, typically using a Fenwick tree or BIT with binary search.Medium6Segment treeBinary search+1No attempts yet0.5s512 MBJudgeable
Candy BoxSupport adding or removing counts of flavored candies and querying/removing the k-th smallest flavor efficiently, using a Fenwick tree with binary search.Medium6Segment treeBinary search+1No attempts yet2s128 MBJudgeable
Mayor Election PostersGiven n posters pasted in order over intervals on a huge wall, count how many posters remain at least partially visible after later posters overlap earlier ones.Medium6Segment treeCombinatorics+2No attempts yet1s192 MBJudgeable
Distances Between Leaf VerticesGiven consecutive-leaf distances of an inorder-numbered binary tree, compute the distance between two arbitrary leaves using a sparse-table style max-range query derived from LCA depth relations.Medium6TreeSegment tree+1No attempts yet2s128 MBJudgeable
Line ReconstructionGiven N heights and, for each position, the count of earlier people with height at most that person's, reconstruct the original front-to-back order.Medium6GreedySorting+1No attempts yet1s128 MBJudgeable
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.Medium6Segment treePrefix sum+1No attempts yet1s256 MBJudgeable
New Array GameSupport left and right rotations on subarray ranges plus point queries on an array of up to 100,000 elements with up to 100,000 operations.Medium6Segment treeArray+1No attempts yet2s128 MBJudgeable
Permutation RankGiven a permutation and many swap queries, compute the lexicographic rank modulo 1e9+7 for each swapped permutation efficiently.Medium6CombinatoricsSegment tree+1No attempts yet2s128 MBJudgeable
Grasshopper JumpsGiven a line of grasshoppers that repeatedly move by jumping left or right over B neighbors, report the maximum height jumped over for each move using an order-statistics/segment-tree-like structure over positions.Medium6Segment treeArray+1No attempts yet2s128 MBJudgeable
Mars MapCompute the total area covered by the union of up to 10,000 axis-aligned rectangles.Medium6Segment treeSorting+1No attempts yet1s128 MBJudgeable
Robotic SortSimulate a specific selection-sort-by-reversal algorithm on samples with stable tie-breaking and report the position used in each reversal step, requiring an efficient order-statistics data structure for up to 100,000 elements.Medium6Segment treeSorting+2No attempts yet1s128 MBJudgeable
Enigmatic DeviceGiven an array, support range squaring modulo 2010 and range sum queries, using the fact that values cycle quickly under repeated squaring.Medium6Segment treeMath+1No attempts yet3s256 MBJudgeable
BillboardSimulate posting strips onto rows of a billboard using a multiset keyed by remaining width, tracking the topmost-leftmost valid row for each strip efficiently.Medium6Segment treeGreedy+2No attempts yet3s256 MBJudgeable
Screen SaverGiven a piecewise linear floor and a water level, update floor heights or the level and report the submerged area to three decimals.Medium6GeometrySegment tree+1No attempts yet2s128 MBJudgeable
Balanced LineupGiven N cow heights and Q ranges, report the difference between the maximum and minimum height within each query range.Medium6Segment treeArray+2No attempts yet1s128 MBJudgeable
CraneGiven a chain of segments with one joint angle changing per command, report the endpoint coordinates after each change within 0.02 and to two decimals.Medium6GeometryMath+2No attempts yet1s128 MBJudgeable
Coding of PermutationsGiven a Lehmer-like code B, decide whether it encodes a permutation of 1..n and if so output that permutation, otherwise print NIE.Medium6Segment treeBinary search+2No attempts yet1s128 MBJudgeable
OperationsMaintain an array of values below k under interval cyclic increments and answer interval sums.Medium6Segment treeNo attempts yet1s128 MBJudgeable
Tower 2Each visitor climbs while taller than each step and stops below the previous visitor, and you report the highest step each one reaches.Medium6Segment treeSimulationNo attempts yet1s128 MBJudgeable
Number of Longest Increasing SubsequencesCount how many strictly increasing subsequences of the given sequence attain the maximum possible length, modulo m.Medium6Dynamic programmingSegment treeNo attempts yet1s128 MBJudgeable
QueriesMaintain a point set under deletions and report the leftmost point within S below the current highest y, breaking ties by higher y.Medium6Segment treeSortingNo attempts yet10s128 MBJudgeable
DominoTopple one domino left or right and count how many fall in the longest chain reaction.Medium6Dynamic programmingBinary search+1No attempts yet1s128 MBJudgeable
Triple ProductsSupport point updates on an array and report, for each queried interval, the sum of products over all triples of distinct positions.Medium6Segment treeMath+1No attempts yet5s128 MBJudgeable
JumpYou remove every k-th number around a circle and print the last three removed numbers for each test case.Medium6MathSimulation+1No attempts yet3s128 MBJudgeable
Mine ClearingFind the most mines covered by one axis-aligned 10 by 10 square placed anywhere on the site.Medium6Sliding windowSorting+1No attempts yet10s512 MBJudgeable
Satellite PhotosCompute the union area of up to 1000 axis-aligned rectangles in each of up to 100 test cases.Medium6GeometrySegment tree+1No attempts yet2s256 MBJudgeable
JuQueenApply point and range frequency steps to cores clamped between 0 and N and report applied steps or queried states.Medium6Segment treeNo attempts yet3s512 MBJudgeable
Excellent EngineersCount the engineers no rival beats in all three skill ranks for each test case.Medium6SortingSegment treeNo attempts yet3s256 MBJudgeable
Catching EggsCount the homes inside each of m axis-parallel rectangles and print the total over all days per test case.Medium6Prefix sumSorting+1No attempts yet5s256 MBJudgeable
Guessing CamelsCount the camel pairs ranked in the same relative order in all three given bets.Medium6Segment treeSorting+1No attempts yet10s512 MBJudgeable
UFOSimulate laser shots that each destroy up to R blocks at height h along one row or column, then find the P by P square holding the most surviving blocks.Medium6Segment treeSimulation+1No attempts yet2s256 MBJudgeable
Bubble SortCompute the array after K left-to-right bubble sort passes over N numbers without simulating every swap.Medium6Segment treeSorting+1No attempts yet1s64 MBJudgeable
Round Robin SchedulerGiven each job's required seconds, compute its finishing time under a round robin scheduler that grants one second per turn in index order.Medium6SortingPrefix sum+1No attempts yet2s512 MBJudgeable
Pat PatAfter point swaps in an array, answer queries asking whether a subarray is nondecreasing.Medium6Segment treeArrayNo attempts yet1s256 MBJudgeable
Colorful VillageMaintain N houses under range repaint operations and answer queries counting how many of the T colors appear in a range.Medium6Segment treeBit manipulation+2No attempts yet2s512 MBJudgeable
Delete the X-th smallest numberMaintain a multiset under insertions and queries that report and delete the X-th smallest element, with values and query count up to 2e6.Medium6Segment treeBinary search+2No attempts yet2s512 MBJudgeable
Sequence and Queries 16Maintain an array under point updates and range queries that ask for the leftmost index of the minimum value in a subarray.Medium6Segment treeArray+2No attempts yet2s512 MBJudgeable
Sequence and Queries 17Maintain an array under point updates and answer range-minimum queries over subarrays.Medium6Segment treeArray+2No attempts yet2s512 MBJudgeable
Array Manipulation at Moloco (Hard)For each position i in a permutation-like array, count how many earlier elements are smaller than A[i], with n up to one million.Medium6Segment treeBinary search+2No attempts yet2s512 MBJudgeable
PicnicGiven N students in a circle removing every K-th person Josephus-style, find the round number in which a specific student M is eliminated, with N and K up to 5,000,000.Medium7Segment treeSimulation+2No attempts yet1s128 MBJudgeable
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.Medium7SortingSegment tree+2No attempts yet2s128 MBJudgeable
Binary Search TreeGiven the insertion order of 0..N-1 values, compute the sum of node heights in the resulting binary search tree efficiently for N up to 250000.Medium7TreeDivide and conquer+2No attempts yet2s256 MBJudgeable
Maximum Increasing Rectangle SetGiven N rectangles, find the maximum subset that can be strictly ordered by lower-left to upper-right containment, solvable via DP with a segment tree over compressed coordinates.Medium7Dynamic programmingSegment tree+2No attempts yet2s128 MBJudgeable
Tap DanceMaintain, after each single-character flip in a binary string, the length of the longest alternating (no two equal adjacent) substring, supporting online point updates.Medium7Segment treeString+1No attempts yet1s128 MBJudgeable
LRH PlantsGiven plants added over time with increasing heights, count for each new plant how many crossing points appear where its stems cross earlier plants' horizontal segments or vice versa, avoiding duplicate points.Medium7Segment treeGeometry+2No attempts yet1s128 MBJudgeable
QueueSimulate people repeatedly leaving a queue and reinserting before another person, then answer position and label lookup queries efficiently using a balanced structure like a Fenwick tree or order-statistics tree.Medium7Segment treeBinary search+2No attempts yet2s32 MBJudgeable
SubmarinesMaintain a sequence under adjacent swaps and repeatedly report the maximum in-degree in the 'nearest deeper element behind' functional graph.Medium7StackSegment tree+1No attempts yet3s128 MBJudgeable
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.Medium7Segment treeBinary search+2No attempts yet2s128 MBJudgeable
TrapezoidsPick the most pairwise disjoint trapezoids between two lines and count those optimal sets modulo 30013.Medium7Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
Jupiter Attacks!Maintain an array under point updates and queries of a polynomial hash over a subarray modulo a prime, printing each hash result.Medium7Segment treePrefix sum+2No attempts yet1s128 MBJudgeable
The Suffering DwarvesMaintain a permutation under swaps and answer whether the set of heights A through B occupies consecutive positions.Medium7Segment treeArray+2No attempts yet1s512 MBJudgeable
SeatingTrack seats in a row under arrivals needing the lowest block of p empty seats and range departures; count the parties turned away.Medium7Segment treeBinary search+2No attempts yet1s128 MBJudgeable
BookshelfPartition the books, in order, into shelves of total width at most L to minimize the sum of each shelf's max height.Medium7Dynamic programmingSegment tree+1No attempts yet1s128 MBJudgeable
City HorizonGiven N axis-aligned rectangles that all rest on the ground, compute the area of their union.Medium7Segment treeDivide and conquer+2No attempts yet1s128 MBJudgeable
AtlantisGiven up to 100 axis-aligned rectangles, compute the area of their union and print it with two decimals.Medium7GeometrySegment tree+2No attempts yet1s128 MBJudgeable
TourneyMaintain a single-elimination bracket of 2^N players under point updates, and answer queries about the winner's position and how many rounds a given player wins.Medium7TreeSegment tree+2No attempts yet2s512 MBJudgeable
WowowMaintain a dynamic set of (id, rating) friends under insertions, rating updates, and queries for the id holding the K-th highest rating.Medium7Segment treeBinary search+2No attempts yet2s512 MBJudgeable
Unreal EstateGiven up to 5000 rectangles with real coordinates, compute the total area their union covers, counting overlaps once, and print it rounded to two decimals.Medium7GeometrySorting+2No attempts yet10s128 MBJudgeable
Stock ExchangeAnswer m online queries, each counting prices in a day range that fall within a decoded value range.Medium7Divide and conquerSegment tree+2No attempts yet7s32 MBJudgeable
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.Medium7Segment treeArray+2No attempts yet3s128 MBJudgeable
MegalopolisCount, for each query at a given moment, the number of still-country roads on the path from village 1 to a target village as edges are removed one by one.Medium7TreeDFS+1No attempts yet1s128 MBJudgeable
ParenthesesFlip or query bracket words under updates; answer whether the current string is a correct bracket expression.Medium7Segment treeImplementationNo attempts yet1s128 MBJudgeable
Fiber Optic NetworkReserve bandwidth on tree paths for connect requests when capacity allows and release per-pair reservations on disconnect.Medium7Segment treeTree+1No attempts yet1s128 MBJudgeable
MechagodzillaAfter each swap of two program letters, decide if the automaton run from the start state ends in a battle state.Medium7Segment treeSimulationNo attempts yet1s128 MBJudgeable
PhotosFind the point covered by the largest number of given axis-aligned rectangles.Medium7Segment treeSorting+1No attempts yet1s512 MBJudgeable
The StructureA tower splits the top load equally down its columns, and after each strength update you report how many queued visitors from the front it can hold.Medium7Segment treePrefix sum+1No attempts yet1s128 MBJudgeable
Friendly PointsCount the pairs of points whose axis-aligned rectangle contains no other point strictly inside.Medium7Segment treeSorting+1No attempts yet1s128 MBJudgeable
SubspeciesCount for each specimen how many others differ by at most D in length, W in weight, and S in segments.Medium7Divide and conquerSorting+2No attempts yet10s128 MBJudgeable
Bazza and ShazzaPoint updates set grid cells to new values and each query asks for the GCD of all values inside a rectangle.Medium7Segment treeNumber theory+1No attempts yet13s230 MBJudgeable