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
Go up the UltrasThe program reads an altitude profile of up to 100000 points and prints the indices of every peak with prominence of at least 150000 centimeters.Medium7StackSegment treeNo attempts yet1s128 MBJudgeable
Genetic engineeringDelete the fewest elements so the rest splits into blocks of k equal values, and print the lexicographically smallest among the longest such genomes.Medium7Dynamic programmingGreedy+1No attempts yet1s128 MBJudgeable
BlanketsCompute the average pairwise overlap area of n identical axis-aligned rectangles from their corner positions.Medium7Segment treeSorting+2No attempts yet1s128 MBJudgeable
Optimal MilkingEach day one machine value changes, then choose nonadjacent machines with maximum total output and add it to the overall sum.Medium7Segment treeDynamic programmingNo attempts yet1s128 MBJudgeable
Airplane BoardingCows walk single-file to assigned seats and each blocks the line while stowing baggage, so compute the time until every cow sits.Medium7Segment treeSimulationNo attempts yet1s128 MBJudgeable
Traveling SagaPrint the order in which an apple from vertex 1 visits every tree vertex by always moving to the farthest unvisited vertex, breaking ties by largest index.Medium7TreeSegment tree+1No attempts yet3s256 MBJudgeable
The Lazy CowChoose a start point to maximize the total grass of patches within Manhattan distance K of it.Medium7Sliding windowSorting+2No attempts yet1s128 MBJudgeable
CouriersGiven the courier numbers in shipment order, report the courier that appears more than half the time in each query interval, or 0 if none does.Medium7Segment treeBinary searchNo attempts yet3s512 MBJudgeable
The Little BirdA bird jumps from tree 1 to tree n in flights of at most k and minimizes landings on trees at least as tall as the takeoff tree.Medium7Dynamic programmingStack+1No attempts yet2s256 MBJudgeable
TeamsSplit the row into the most contiguous teams so each student's team size lies within their given range, and count those optimal splits.Medium7Dynamic programmingSegment tree+1No attempts yet5s256 MBJudgeable
Ring road bus routesPrint the numbers of the clockwise arcs on an N-stop ring that no other given arc fully covers, in increasing order.Medium7IntervalsSorting+1No attempts yet2s256 MBJudgeable
Flipping ParenthesesAfter each single-bracket flip that breaks a balanced parenthesis string, find the leftmost second flip that restores balance.Medium7Segment treePrefix sumNo attempts yet5s256 MBJudgeable
UFOSimulate K laser shots that each remove the first R cells reaching one layer along a row or column, then find the P by P square with the largest remaining sum.Medium7Segment treeSimulation+2No attempts yet5s256 MBJudgeable
Most Influential PumpkinAfter each range increment on an odd-length array, report the median value of the array.Medium7Segment treeBinary search+1No attempts yet5s256 MBJudgeable
Marathon sub-routesGiven checkpoint coordinates with point updates, report the shortest Manhattan route over each queried interval with at most one interior checkpoint skipped.Medium7Segment treeMathNo attempts yet1s256 MBJudgeable
RukaUpdate vectors of a polyline through cursor commands and report how many segments cross the coordinate axes.Medium7Segment treePrefix sumNo attempts yet2s512 MBJudgeable
City InfluenceAdd N weighted rectangles on a billion by billion grid and print the sum of squared cell values modulo 1,000,000,007.Medium7Segment treeSorting+1No attempts yet2s64 MBJudgeable
Rectangle update and rectangle sumYou add w to all cells in one rectangle per update and print the cell sum of one rectangle per query in order.Medium7Segment treePrefix sum+1No attempts yet1s256 MBJudgeable
Consecutive OrderingDecide whether every vertex's closed neighbourhood forms one unbroken block in the given vertex ordering.Medium7IntervalsTwo pointers+1No attempts yet1s256 MBJudgeable
Bond TourEach parade route is the tree path between two towns, and you report the best contiguous stretch of road weights on it, or zero.Medium7Segment treeTreeNo attempts yet5s256 MBJudgeable
The Running GamePick disjoint segments of the given sequence so the sum of each segment weighted by its position inside the segment is as large as possible.Medium7Dynamic programmingPrefix sum+1No attempts yet1s512 MBJudgeable
Tree of Almost Clean MoneyEach operation adds generated values to up to 1000 vertices and asks for the sum on the path between two vertices.Medium7TreeSegment treeNo attempts yet4s256 MBJudgeable
BitrisFind the fewest adjacent swaps that let all paired cubes cancel by repeatedly deleting equal neighbors.Medium7IntervalsSorting+1No attempts yet1s256 MBJudgeable
Keep it energizedBuy energy packs at level shops so the stored energy covers each level cost in order for the least total cash.Medium7Dynamic programmingSegment tree+2No attempts yet3s256 MBJudgeable
Pyramid Base 2Find the largest axis-aligned square that fits on the grid so the total cost of removing the obstacles it overlaps stays within budget.Medium7Binary searchSegment tree+1No attempts yet5s128 MBJudgeable
Shortest Complete SubarrayProcess point updates on an array and report the length of the shortest contiguous subarray containing every value from 1 to K, or -1 if none exists.Medium7Segment treeSliding window+1No attempts yet3s512 MBJudgeable
Watermelons of the Field of WondersGiven N lines W0 + S*K, report the line with the largest value at each of M query days, breaking ties by smallest index.Medium7Segment treeSorting+1No attempts yet2s256 MBJudgeable
Weighing the stonesAfter each ranked stone is placed on pan 1 or pan 2, report whether pan 1 is heavier under every valid weight assignment, pan 2 is, or neither is certain.Medium7Segment treeGreedy+1No attempts yet1s256 MBJudgeable
Monkey and Apple TreesCount ripe trees in each visited interval while other events ripen whole intervals, with every interval shifted by the previous count.Medium7Segment treeIntervalsNo attempts yet2s256 MBJudgeable
Gold Camp ForcefieldChoose a contiguous group of camps whose total energy covers the distance between its ends to maximize total gold.Medium7Segment treePrefix sum+1No attempts yet1s256 MBJudgeable
K blocksSplit the array into exactly K contiguous blocks so the sum of each block's maximum is as small as possible.Medium7Dynamic programmingStack+1No attempts yet1s256 MBJudgeable
PinballThe program installs the cheapest set of row devices so every falling ball lands in one bottom cell.Medium7Dynamic programmingSegment treeNo attempts yet1s512 MBJudgeable
Cubic ArtGiven a cube state and a move sequence, apply point updates that replace one move and print the resulting cube state after each update.Medium7Segment treeSimulation+2No attempts yet1s1024 MBJudgeable
Range XORMaintain an array under range xor updates and range xor queries, both on subarrays given by index bounds.Medium7Bit manipulationSegment tree+2No attempts yet2s512 MBJudgeable
Reading the stone slabAfter each range replacement on a string, count the number of subsequences equal to a given name of length at most 5, modulo 1e9+7.Medium7Dynamic programmingSegment tree+1No attempts yet4s256 MBJudgeable
First black vertex on a pathFlip vertex colors and, along the root-to-v path, report the first black vertex encountered from the root.Medium7TreeSegment tree+1No attempts yet2s512 MBJudgeable
Maximum weight in a monochromatic componentOn a colored tree, handle color flips, weight updates, and queries for the maximum weight in the monochromatic component containing a vertex.Medium7TreeSegment tree+1No attempts yet2s512 MBJudgeable
Increasing subsequences of length KCount length-K index subsequences whose values are strictly increasing, modulo 5,000,000.Medium7Dynamic programmingSegment tree+2No attempts yet2s512 MBJudgeable
Man, Elephant, and RatMaintain a line of players cycling through three signs; range updates advance each player to the next sign, and range queries report counts of each sign.Medium7Segment treeLinked list+1No attempts yet2s512 MBJudgeable
Performance ReviewFor each employee, sum t_j over all descendants j whose rank r_j is lower than the employee's rank.Medium7TreeDFS+2No attempts yet2s512 MBJudgeable
Promotion CountingFor each node of a rooted tree, count descendants whose value is larger than the node's own value.Medium7TreeDFS+1No attempts yet2s512 MBJudgeable
Venue Rental (Large)Given up to 3000 axis-aligned rectangles, find the total area of their union, counting overlaps once.Medium7GeometrySorting+2No attempts yet5s256 MBJudgeable
Grandpa's QuestionProcess a stream of child-getting-off statements and queries asking for the smallest-numbered child at least B who rode at most Y stops so far.Medium7Segment treeBinary search+1No attempts yet1s64 MBJudgeable
Fundraising DinnerChoose a subset of people with beauty, fortune, and donation so that no two conflict, and the total donation is maximized.Medium7Dynamic programmingSorting+2No attempts yet1s1024 MBJudgeable
Bake OffEach customer in line gets the most delicious remaining cake containing all six requested flavours, or nothing if none exists.Medium7Bit manipulationImplementation+2No attempts yet8s512 MBJudgeable
Escape RoomGiven the longest increasing subsequence length starting at each position, find the lexicographically smallest permutation of 1..N matching these values.Medium7GreedySegment tree+1No attempts yet1s64 MBJudgeable
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.Medium7Dynamic programmingSegment tree+2No attempts yet1.5s64 MBJudgeable
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.Medium7Dynamic programmingSegment tree+1No attempts yet1s128 MBJudgeable
Calculate! 2On a rooted tree, handle subtree XOR queries and subtree XOR updates, printing the XOR of a vertex and its descendants.Medium7TreeSegment tree+2No attempts yet1s512 MBJudgeable
Junha's Number Theory Assignment (Divmaster)Process Q operations on N natural numbers: replace a range with each value's divisor count, or print a range sum. Skip settled ranges using the fast convergence of divisor counts.Medium7Segment treeMath+2No attempts yet1s256 MBJudgeable
Tree and GahuiIn a heap-indexed complete binary tree, answer subtree-size queries and subtree-removal queries as nodes get deleted over time.Medium7TreeSegment tree+2No attempts yet1.5s512 MBJudgeable
Points and RectanglesProcess point insertions and rectangle insertions online, after each query reporting how many (point, rectangle) pairs have the point inside or on the rectangle.Medium7Segment treePrefix sum+2No attempts yet2s512 MBJudgeable
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.Medium7Segment treeArray+2No attempts yet5s512 MBJudgeable
Raider Choragi and Queries (Easy)Zones form a cycle; a squad covers one or two adjacent zones holding at most W prisoners. After each point update report the minimum number of squads covering all zones.Medium7Dynamic programmingGreedy+2No attempts yet1s256 MBJudgeable
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.Medium7Segment treePrefix sum+2No attempts yet2s512 MBJudgeable
Sequence and Queries 1.5Maintain an array under point updates and answer range queries counting how many elements in a subarray exceed k.Medium7Segment treeSorting+2No attempts yet1.5s512 MBJudgeable
Longest Increasing Subsequence 6For a sequence of up to one million integers, report the length of the longest strictly increasing subsequence and the number of such subsequences modulo 1e9+7.Medium7Dynamic programmingBinary search+2No attempts yet2s512 MBJudgeable
KoalaGiven houses on a line, a max jump length, and stamina costs, find the maximum stamina on arrival when each tutor house can be used once.Medium7Dynamic programmingGreedy+2No attempts yet2s256 MBJudgeable
Gameworld TornadoGiven up to 100000 axis-aligned rectangles, find the total area of their union.Medium7GeometrySorting+2No attempts yet2s512 MBJudgeable
WinteringMaintain acorn counts on a circular walkway split into contiguous regions, supporting range additions and range sum queries over possibly wrapping cell intervals.Medium7Segment treePrefix sum+2No attempts yet2s256 MBJudgeable
Stacking horizontal blocksDrop N horizontal blocks one by one at fixed positions, each landing on the tallest surface below it, and report the final stack height.Medium7Segment treeBinary search+2No attempts yet1s512 MBJudgeable
Company Culture 5A supervisor tree supports turning all subordinates of a worker on or off, and counting how many subordinates of a worker are currently on. Initially only the computer of node 1 is on.Medium7TreeDFS+2No attempts yet2s512 MBJudgeable
Christmas TreeMaintain a dynamic set of colored nodes in a rooted tree under insertions and deletions, and after each update report the lowest common ancestor of all colored nodes.Medium7TreeDFS+2No attempts yet2s512 MBJudgeable
Random GeneratorSimulate repeatedly picking the p-th remaining copy from a multiset where value i appears w_i times, and output the order in which values are exhausted.Medium7Segment treeBinary search+2No attempts yet1s1024 MBJudgeable
BusGiven passenger groups each traveling between two bus stops, choose how many from each group to carry so total passengers are maximized without exceeding capacity C on any segment.Hard8GreedySegment tree+1No attempts yet2s128 MBJudgeable
Feeding the PandaFind the longest sequence of bamboo groves with strictly increasing tastiness where consecutive Manhattan distance stays within the destination's bamboo count.Hard8Dynamic programmingGeometry+2No attempts yet2s128 MBJudgeable
Perimeter of a Rectangle UnionCompute the total outer perimeter of the union of up to 5000 axis-aligned rectangles using a sweep-line approach.Hard8SortingGeometry+1No attempts yet2s128 MBJudgeable
Microbiology LabChoose the minimum number of distinct integer temperature points so every microbe's interval contains at least C[i] chosen points.Hard8GreedySegment tree+2No attempts yet2s128 MBJudgeable
World-Famous Oil MagnateMaintain tree heights under two operations, fertilize the C smallest trees whose height is at least H by raising each by 1, and answer range count queries, efficiently.Hard8Segment treeBinary search+1No attempts yet1s128 MBJudgeable
Richest Tenant CompanyProcess chronological move-ins and range-max inspections on offices where each company's wealth grows linearly with time, requiring a segment tree over linear functions evaluated at the query day.Hard8Segment treeIntervals+1No attempts yet5s128 MBJudgeable
Dynamic Sequence Data StructureDesign a data structure supporting range assignment, range arithmetic-progression addition, mid-sequence insertion, and range-sum queries efficiently.Hard8Segment treeArray+1No attempts yet1s128 MBJudgeable
Mysterious ObjectSupport range updates that overwrite box X in [L,R] with ((X-L+1)*A) mod B, and answer range-sum queries over up to 10^9 boxes with 50000 operations.Hard8Segment treeMath+1No attempts yet8s128 MBJudgeable
Antarctic ExpeditionProcess bridge, penguin-update, and route-sum queries on an incrementally connected forest, requiring dynamic connectivity checks and path-sum queries under updates.Hard8Union-findTree+2No attempts yet5s128 MBJudgeable
Frog PrincessSimulate a frog jumping to the nearest plant along diagonal directions, removing the departed plant each time, over up to 100,000 moves and plants.Hard8Segment treeSimulation+2No attempts yet1s128 MBJudgeable
Wangnuni the FrogFind the path from leaf 1 to leaf N using only rightward or upward axis-aligned jumps costing K power each, that maximizes leftover power after eating flies along the way.Hard8Dynamic programmingSorting+1No attempts yet1s128 MBJudgeable
Rectangles in Three DimensionsGiven N axis-aligned rectangles in 3D each parallel to one coordinate plane, count pairs of rectangles that intersect in at least one point.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
Study Leader HongjunMaintain a dynamic set of (A,B) student pairs supporting insertion and queries for the student with minimal B difference (tie-broken by minimal A difference) among those with B >= B_i and A > A_i or (B=B_i and A>A_i).Hard8Segment treeBinary search+1No attempts yet3s128 MBJudgeable
GrassSimulate N up to 1e9 plants under growth, cap, mow-left, mow-right, and clamp operations using an implicit interval structure, answering running sum queries efficiently.Hard8Segment treeIntervals+2No attempts yet1s128 MBJudgeable
FlowersFor each flower, find the rectangle formed by nearest boundary hits in four directions and count strictly interior flowers, using offline sweeps and range structures.Hard8SortingSegment tree+1No attempts yet1s128 MBJudgeable
AntsGiven a forest of towns formed by persistent range-add copies of parent towns, answer range-sum queries on each newly created version using online, XOR-derived parameters that depend on previous answers.Hard8Segment treePrefix sum+2No attempts yet3s128 MBJudgeable
Horizontally Visible SegmentsGiven disjoint vertical segments, count triangles formed by triples that are pairwise horizontally visible using a sweep and visibility structure.Hard8SortingGeometry+1No attempts yet1s128 MBJudgeable
FlightsFor each query, find the maximum altitude among a subset of parabolic missile trajectories (indexed by launch time) restricted to a horizontal range, and output the exact reduced fraction.Hard8GeometrySegment tree+2No attempts yet3s1024 MBJudgeable
MountainsMaintain a piecewise-constant sequence of elevation changes under range assignments, and after each update find the first prefix-sum position whose elevation exceeds a query height h.Hard8Segment treeBinary search+2No attempts yet3s256 MBJudgeable
Area and Perimeter of a Union of RectanglesGiven up to 10000 axis-parallel rectangles on an integer grid, compute the area of their union (and its perimeter when r=2), counting overlaps once.Hard8Segment treeSorting+2No attempts yet1s128 MBJudgeable
Jousting TournamentGiven the starting order of N-1 knights and C fixed round intervals, find the smallest insertion position for a late knight with skill R that maximizes the number of rounds it wins.Hard8ArraySimulation+2No attempts yet1s256 MBJudgeable
ElephantsAfter each of M moves that relocate one elephant, report the minimum number of length-L segments needed to cover all current positions.Hard8Segment treeDynamic programming+2No attempts yet12s256 MBJudgeable
Route DesignGiven two banks of valued sites and a set of non-crossing routes, find the maximum total value of a tour that alternates between banks without intersecting routes.Hard8Dynamic programmingSorting+2No attempts yet1s128 MBJudgeable
Farm ManagementA tree of N farms gets path updates that add 1 to every edge on a path, plus path queries that sum edge values on a path; process M operations online.Hard8TreeSegment tree+2No attempts yet1s128 MBJudgeable
Barn AllocationGiven stall capacities and interval requests, find the maximum number of requests that can be granted without any stall exceeding its capacity.Hard8GreedySegment tree+2No attempts yet2s128 MBJudgeable
Safe TravelFor each pasture i, find the shortest path from pasture 1 to i that avoids the last edge of the unique shortest path to i.Hard8GraphShortest path+1No attempts yet3s128 MBJudgeable
Holiday PaintingPaint rectangle updates on an R x C grid, R up to 50000 and C up to 15, and after each of Q updates report how many cells equal a fixed target pattern.Hard8Segment treeBit manipulation+2No attempts yet2s128 MBJudgeable
HotelProcess check-in and check-out requests on a row of hotel rooms, always assigning the leftmost block of the requested length, or 0 if none fits.Hard8Segment treeDivide and conquer+1No attempts yet1s128 MBJudgeable
Frequent ValuesFor each range query on a sorted array, output how many times the most frequent value occurs inside the range.Hard8Segment treeDivide and conquer+1No attempts yet1s128 MBJudgeable
The K-th NumberGiven an array of distinct integers and m range queries, return the k-th smallest value inside each queried subarray.Hard8Binary searchDivide and conquer+2No attempts yet1s256 MBJudgeable
PlatformsGiven points with distinct x, find the longest chain of flights where each next point has larger x and no larger y, then report every point lying on some longest chain.Hard8Dynamic programmingSorting+2No attempts yet2s128 MBJudgeable
Box ArtGiven a bounding box and up to 2000 axis-aligned boxes, compute the volume of their union clipped to the bounding box.Hard8GeometrySorting+2No attempts yet1s128 MBJudgeable
RectanglesGiven N axis-aligned rectangles, compute the area of their union.Hard8Segment treeSorting+1No attempts yet3s128 MBJudgeable
Rectangles Too!Find the longest chain of rectangles where each rectangle lies strictly below and to the left of the next one.Hard8SortingDynamic programming+1No attempts yet3s128 MBJudgeable
Union Area of TrianglesGiven right isosceles triangles with axis-parallel legs and hypotenuse of slope -1, compute the area of their union.Hard8GeometrySegment tree+2No attempts yet1s32 MBJudgeable
Log AnalysisMaintain a volatile log under insertions in the middle, block deletions, and queries asking how many distinct event types appear in a position range.Hard8ArraySegment tree+2No attempts yet2s256 MBJudgeable