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
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Minimum valueAnswer up to 100,000 range minimum queries over a static array of up to 100,000 integers. | Easy3 | Segment tree | No attempts yet | 1s | 256 MB | Judgeable |
| BeadsProcess point additions to boxes and answer range-sum queries in order for each game. | Easy3 | Segment tree | No attempts yet | 1s | 256 MB | Judgeable |
| Sequence and Queries 37Maintain an array under point updates, and for range queries report how many entries are even or odd. | Easy3 | ArrayPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Coffee Shop Game 2Given an array, answer Q online queries each asking a range sum (with swapped bounds allowed) followed by a point update. | Medium4 | Segment treePrefix sum+1 | No attempts yet | 2s | 256 MB | Judgeable |
| 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. | Medium4 | Segment treeArray+1 | No attempts yet | 2s | 256 MB | Judgeable |
| 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. | Medium4 | Segment treePrefix sum+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Minimum and MaximumGiven N numbers and M range queries, output the minimum and maximum value within each query's index range. | Medium4 | Segment treeArray | No attempts yet | 2s | 192 MB | Judgeable |
| CannonsFor each query, report the minimum and maximum value in the given subarray of cannon strengths. | Medium4 | Segment treeArray | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium4 | Segment tree | No attempts yet | 2s | 256 MB | Judgeable |
| 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. | Medium4 | Segment treePrefix sum | No attempts yet | 1s | 256 MB | Judgeable |
| Range Add and Range SumProcess range additions on a sequence and print the sum of each queried range in order. | Medium4 | Segment tree | No attempts yet | 2s | 256 MB | Judgeable |
| Range product queriesAnswer range product queries modulo 1,000,000,007 on a sequence with point updates. | Medium4 | Segment tree | No attempts yet | 1s | 256 MB | Judgeable |
| Table Range Sum with UpdatesApply point updates on an N by N table and answer each rectangle sum query in order. | Medium4 | Segment tree | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Medium4 | Segment treeIntervals | No attempts yet | 2s | 64 MB | Judgeable |
| Counting HaybalesApply range additions to N fields and answer Q range-minimum and range-sum queries in order. | Medium4 | Segment tree | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Medium5 | Segment treeIntervals+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Drunk CodingMaintain a sequence under point updates and answer range-product sign queries (+/-/0) for each test case until EOF. | Medium5 | Segment treePrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Switching LightsMaintain a binary array of N lights under M range-toggle and range-count operations, and print each query result. | Medium5 | Segment treeArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Balanced LineupGiven a static array of cow heights, answer queries giving the max minus min over each range [A, B]. | Medium5 | Segment treeArray | No attempts yet | 1s | 128 MB | Judgeable |
| Two WordsAfter each swap of one character between the two strings, report which string is lexicographically larger. | Medium5 | Segment treeString | No attempts yet | 1s | 512 MB | Judgeable |
| Reconstruct the QueueGiven each arrival's insertion spot in a growing queue, compute every person's final position at dispersal. | Medium5 | Segment tree | No attempts yet | 1s | 128 MB | Judgeable |
| RankingsPlayers accumulate points through updates and each query asks for the current rank of one player among up to 100000 players. | Medium5 | Segment treeSorting+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Incomparable rectangle pairsCount the pairs of rectangles where neither fits inside the other after translation or a 90-degree rotation. | Medium5 | SortingGeometry+1 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Medium5 | Segment treeTree | No attempts yet | 10s | 256 MB | Judgeable |
| Lunch MenuCount the menus whose spiciness falls in [u, v] and whose sweetness falls in [x, y] for each query. | Medium5 | Segment treeSorting+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Sequence and Queries 15Maintain an array under point updates and, after each change, report the smallest index holding the minimum value. | Medium5 | Segment treeImplementation | No attempts yet | 1s | 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 |
| 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 |
| Permutation RestorationGiven the inversion sequence of a permutation of 1..N, reconstruct the original permutation using an efficient data structure. | Medium6 | Segment treeBinary search+2 | No attempts yet | 0.55s | 128 MB | Judgeable |
| Bubble SortGiven an array, find the value of loop counter i when an early-exit bubble sort finishes sorting it. | Medium6 | SortingArray+2 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Medium6 | Segment treeBinary search+1 | No attempts yet | 0.5s | 512 MB | Judgeable |
| 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. | Medium6 | Segment treeBinary search+1 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Medium6 | Segment treeCombinatorics+2 | No attempts yet | 1s | 192 MB | Judgeable |
| 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. | Medium6 | TreeSegment tree+1 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Medium6 | GreedySorting+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 |
| 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. | Medium6 | Segment treeArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Permutation RankGiven a permutation and many swap queries, compute the lexicographic rank modulo 1e9+7 for each swapped permutation efficiently. | Medium6 | CombinatoricsSegment tree+1 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Medium6 | Segment treeArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Mars MapCompute the total area covered by the union of up to 10,000 axis-aligned rectangles. | Medium6 | Segment treeSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | Segment treeSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Enigmatic DeviceGiven an array, support range squaring modulo 2010 and range sum queries, using the fact that values cycle quickly under repeated squaring. | Medium6 | Segment treeMath+1 | No attempts yet | 3s | 256 MB | Judgeable |
| 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. | Medium6 | Segment treeGreedy+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Screen SaverGiven a piecewise linear floor and a water level, update floor heights or the level and report the submerged area to three decimals. | Medium6 | GeometrySegment tree+1 | No attempts yet | 2s | 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 |
| 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. | Medium6 | GeometryMath+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium6 | Segment treeBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| OperationsMaintain an array of values below k under interval cyclic increments and answer interval sums. | Medium6 | Segment tree | No attempts yet | 1s | 128 MB | Judgeable |
| Tower 2Each visitor climbs while taller than each step and stops below the previous visitor, and you report the highest step each one reaches. | Medium6 | Segment treeSimulation | No attempts yet | 1s | 128 MB | Judgeable |
| Number of Longest Increasing SubsequencesCount how many strictly increasing subsequences of the given sequence attain the maximum possible length, modulo m. | Medium6 | Dynamic programmingSegment tree | No attempts yet | 1s | 128 MB | Judgeable |
| QueriesMaintain a point set under deletions and report the leftmost point within S below the current highest y, breaking ties by higher y. | Medium6 | Segment treeSorting | No attempts yet | 10s | 128 MB | Judgeable |
| DominoTopple one domino left or right and count how many fall in the longest chain reaction. | Medium6 | Dynamic programmingBinary search+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Triple ProductsSupport point updates on an array and report, for each queried interval, the sum of products over all triples of distinct positions. | Medium6 | Segment treeMath+1 | No attempts yet | 5s | 128 MB | Judgeable |
| JumpYou remove every k-th number around a circle and print the last three removed numbers for each test case. | Medium6 | MathSimulation+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Mine ClearingFind the most mines covered by one axis-aligned 10 by 10 square placed anywhere on the site. | Medium6 | Sliding windowSorting+1 | No attempts yet | 10s | 512 MB | Judgeable |
| Satellite PhotosCompute the union area of up to 1000 axis-aligned rectangles in each of up to 100 test cases. | Medium6 | GeometrySegment tree+1 | No attempts yet | 2s | 256 MB | Judgeable |
| JuQueenApply point and range frequency steps to cores clamped between 0 and N and report applied steps or queried states. | Medium6 | Segment tree | No attempts yet | 3s | 512 MB | Judgeable |
| Excellent EngineersCount the engineers no rival beats in all three skill ranks for each test case. | Medium6 | SortingSegment tree | No attempts yet | 3s | 256 MB | Judgeable |
| Catching EggsCount the homes inside each of m axis-parallel rectangles and print the total over all days per test case. | Medium6 | Prefix sumSorting+1 | No attempts yet | 5s | 256 MB | Judgeable |
| Guessing CamelsCount the camel pairs ranked in the same relative order in all three given bets. | Medium6 | Segment treeSorting+1 | No attempts yet | 10s | 512 MB | Judgeable |
| 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. | Medium6 | Segment treeSimulation+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Bubble SortCompute the array after K left-to-right bubble sort passes over N numbers without simulating every swap. | Medium6 | Segment treeSorting+1 | No attempts yet | 1s | 64 MB | Judgeable |
| 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. | Medium6 | SortingPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Pat PatAfter point swaps in an array, answer queries asking whether a subarray is nondecreasing. | Medium6 | Segment treeArray | No attempts yet | 1s | 256 MB | Judgeable |
| Colorful VillageMaintain N houses under range repaint operations and answer queries counting how many of the T colors appear in a range. | Medium6 | Segment treeBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Medium6 | Segment treeBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Medium6 | Segment treeArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Sequence and Queries 17Maintain an array under point updates and answer range-minimum queries over subarrays. | Medium6 | Segment treeArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Medium6 | Segment treeBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 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. | Medium7 | Segment treeSimulation+2 | No attempts yet | 1s | 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 |
| 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. | Medium7 | TreeDivide and conquer+2 | No attempts yet | 2s | 256 MB | Judgeable |
| 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. | Medium7 | Dynamic programmingSegment tree+2 | No attempts yet | 2s | 128 MB | Judgeable |
| 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. | Medium7 | Segment treeString+1 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium7 | Segment treeGeometry+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium7 | Segment treeBinary search+2 | No attempts yet | 2s | 32 MB | Judgeable |
| SubmarinesMaintain a sequence under adjacent swaps and repeatedly report the maximum in-degree in the 'nearest deeper element behind' functional graph. | Medium7 | StackSegment tree+1 | No attempts yet | 3s | 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 |
| TrapezoidsPick the most pairwise disjoint trapezoids between two lines and count those optimal sets modulo 30013. | Medium7 | Dynamic programmingSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Jupiter Attacks!Maintain an array under point updates and queries of a polynomial hash over a subarray modulo a prime, printing each hash result. | Medium7 | Segment treePrefix sum+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 |
| 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 |
| BookshelfPartition the books, in order, into shelves of total width at most L to minimize the sum of each shelf's max height. | Medium7 | Dynamic programmingSegment tree+1 | No attempts yet | 1s | 128 MB | Judgeable |
| City HorizonGiven N axis-aligned rectangles that all rest on the ground, compute the area of their union. | Medium7 | Segment treeDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| AtlantisGiven up to 100 axis-aligned rectangles, compute the area of their union and print it with two decimals. | Medium7 | GeometrySegment tree+2 | No attempts yet | 1s | 128 MB | Judgeable |
| 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. | Medium7 | TreeSegment tree+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 |
| 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. | Medium7 | GeometrySorting+2 | No attempts yet | 10s | 128 MB | Judgeable |
| Stock ExchangeAnswer m online queries, each counting prices in a day range that fall within a decoded value range. | Medium7 | Divide and conquerSegment tree+2 | No attempts yet | 7s | 32 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 |
| 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. | Medium7 | TreeDFS+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ParenthesesFlip or query bracket words under updates; answer whether the current string is a correct bracket expression. | Medium7 | Segment treeImplementation | No attempts yet | 1s | 128 MB | Judgeable |
| Fiber Optic NetworkReserve bandwidth on tree paths for connect requests when capacity allows and release per-pair reservations on disconnect. | Medium7 | Segment treeTree+1 | No attempts yet | 1s | 128 MB | Judgeable |
| MechagodzillaAfter each swap of two program letters, decide if the automaton run from the start state ends in a battle state. | Medium7 | Segment treeSimulation | No attempts yet | 1s | 128 MB | Judgeable |
| PhotosFind the point covered by the largest number of given axis-aligned rectangles. | Medium7 | Segment treeSorting+1 | No attempts yet | 1s | 512 MB | Judgeable |
| 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. | Medium7 | Segment treePrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Friendly PointsCount the pairs of points whose axis-aligned rectangle contains no other point strictly inside. | Medium7 | Segment treeSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| SubspeciesCount for each specimen how many others differ by at most D in length, W in weight, and S in segments. | Medium7 | Divide and conquerSorting+2 | No attempts yet | 10s | 128 MB | Judgeable |
| Bazza and ShazzaPoint updates set grid cells to new values and each query asks for the GCD of all values inside a rectangle. | Medium7 | Segment treeNumber theory+1 | No attempts yet | 13s | 230 MB | Judgeable |