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 |
|---|---|---|---|---|---|---|
| XH CompanyFor each query day D, report the length of the shortest suffix ending on day D-1 with the largest average. | Medium7 | StackPrefix sum+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Flipping ParenthesesAfter each single-bracket flip that breaks a balanced parenthesis string, find the leftmost second flip that restores balance. | Medium7 | Segment treePrefix sum | No attempts yet | 5s | 256 MB | Judgeable |
| 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. | Medium7 | Segment treeSimulation+2 | No attempts yet | 5s | 256 MB | Judgeable |
| Strange AntennasCount grid cells covered by an odd number of diagonal triangular antenna signals. | Medium7 | GeometryPrefix sum+1 | No attempts yet | 5s | 256 MB | Judgeable |
| Kebab HouseCount subsets of the work seconds with gaps of at least t+1 such that each kebab misses at most q_i minus x_i ingredients, modulo 1e9+7. | Medium7 | Dynamic programmingCombinatorics+1 | No attempts yet | 2s | 256 MB | Judgeable |
| GatheringPick an integer intersection within Manhattan distance d of every house so the sum of Manhattan travel distances is smallest, or report impossible. | Medium7 | GeometrySorting+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Third Round StandingsGiven two rounds of scores from 0 to 650, the task asks each contestant's highest and lowest final rank over third-round scores that respect dominance. | Medium7 | Prefix sumGreedy | No attempts yet | 1s | 32 MB | Judgeable |
| Cube ColoringCount the cubes in an X by Y by Z box by Manhattan distance from a given cube modulo N. | Medium7 | CombinatoricsPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| WTF TransformationChoose the ID array that maximizes the two-phase rotating sum and output that maximum with the lexicographically smallest optimal ID array. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Fortress WallCount square one-cell-thick borders of size at least L that fit in an H by W grid without covering a tree. | Medium7 | Prefix sumMatrix | No attempts yet | 10s | 512 MB | Judgeable |
| Slave to achievements 1Craft as many N-cost daggers as possible and reclaim 0-to-K chips per dagger until fewer than N remain then print each final remainder probability modulo 1e9+7. | Medium7 | Dynamic programmingProbability+2 | No attempts yet | 3s | 256 MB | Judgeable |
| Rotating the KeyringCount all wrong key tries made while doors 1 to N are unlocked in cyclic order K times with a rotating keyring. | Medium7 | ArrayMath+1 | No attempts yet | 1s | 64 MB | Judgeable |
| Cow HopscotchCount paths from the top-left to the bottom-right cell moving down and right where consecutive cells hold different values. | Medium7 | Dynamic programmingPrefix sum | No attempts yet | 1s | 256 MB | Judgeable |
| Queen BeeSimulate N days of growth on an M by M grid where each inner cell copies the largest daily growth among its left, upper-left, and upper neighbors. | Medium7 | Dynamic programmingPrefix sum | No attempts yet | 2s | 256 MB | Judgeable |
| Palembang BridgesChoose positions for up to two bridges so the total driving distance of all citizens is minimized. | Medium7 | SortingGreedy+1 | No attempts yet | 2s | 256 MB | Judgeable |
| RukaUpdate vectors of a polyline through cursor commands and report how many segments cross the coordinate axes. | Medium7 | Segment treePrefix sum | No attempts yet | 2s | 512 MB | Judgeable |
| Block StackingCount distinct front-view colorings of supported stacks of width W and height at most H built from unlimited blocks of widths 1 to K, modulo 1e9+7. | Medium7 | Dynamic programmingCombinatorics+1 | No attempts yet | 1s | 32 MB | Judgeable |
| City InfluenceAdd N weighted rectangles on a billion by billion grid and print the sum of squared cell values modulo 1,000,000,007. | Medium7 | Segment treeSorting+1 | No attempts yet | 2s | 64 MB | Judgeable |
| Covering the gridPlace corner-touching rectangles chaining from the top-left cell to the bottom-right cell to maximize the sum of covered cell values. | Medium7 | Dynamic programmingPrefix sum | No attempts yet | 1s | 256 MB | Judgeable |
| Unique right triangleCount the perimeters up to N that form exactly one integer-sided right triangle. | Medium7 | Number theoryArray+1 | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Medium7 | Segment treePrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Icons in the ToolbarPlace 2N squares with given side lengths into a 2 by N grid so the product of the summed row heights and summed column widths is minimal. | Medium7 | GreedySorting+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Spam FilterFind the contiguous block of at least k binary results with the highest share of ones, breaking ties by earliest start then shortest length. | Medium7 | Binary searchPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| 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. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 1s | 512 MB | Judgeable |
| RainfallChoose when to leave and how fast to ride within T minutes to minimize trip rain plus sweat that grows with the square of speed. | Medium7 | MathPrefix sum+1 | No attempts yet | 5s | 256 MB | Judgeable |
| TelescopeCount the 4-connected white regions of a binary sky given only its N by N averaged and rounded-down picture. | Medium7 | GreedyPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Keep it energizedBuy energy packs at level shops so the stored energy covers each level cost in order for the least total cash. | Medium7 | Dynamic programmingSegment tree+2 | No attempts yet | 3s | 256 MB | Judgeable |
| LCM(i, j)Add the least common multiple over every pair i<j up to n and print the remainder modulo 1,000,000,007. | Medium7 | Number theoryMath+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Delete This!Find the fewest icons to move so a single box encloses all delete centers and excludes all keep centers. | Medium7 | GeometryPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Jumping JoeyA frog visits pads in order, pulls ropes to drag upcoming pads closer, jumps gaps up to D, swims the rest, and needs the fewest swims. | Medium7 | Dynamic programmingGreedy+1 | No attempts yet | 3s | 256 MB | Judgeable |
| Building a Scholarship TableCount CGPA range tables with equal widths and arithmetic rates that spend exactly P units on the given students. | Medium7 | Brute forceMath+1 | No attempts yet | 4s | 256 MB | Judgeable |
| 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. | Medium7 | Segment treeGreedy+1 | No attempts yet | 1s | 256 MB | Judgeable |
| XORPrint the start and length of the longest contiguous segment whose xor is at least x. | Medium7 | TrieBit manipulation+1 | No attempts yet | 5s | 256 MB | Judgeable |
| Gold Camp ForcefieldChoose a contiguous group of camps whose total energy covers the distance between its ends to maximize total gold. | Medium7 | Segment treePrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Circular BarnChoose up to k outer doors on a ring of n rooms so the total clockwise walking distance to every cow room is minimized. | Medium7 | Dynamic programmingPrefix sum | No attempts yet | 2s | 512 MB | Judgeable |
| Circular BarnAssign each cow waiting outside n rooms on a ring to a distinct room clockwise ahead so the sum of squared walking distances is as small as possible. | Medium7 | GreedyPrefix sum | No attempts yet | 2s | 512 MB | Judgeable |
| Circular Barn RevisitedFarmer John opens k doors on a ring of n rooms so cows walking clockwise to their assigned rooms travel the smallest total distance. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Sums of Sums (Large)Given a positive array, sort all its subarray sums and answer the sum of entries ranked L through R for each query. | Medium7 | Binary searchTwo pointers+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Pretty Good Proportion (Large)Given a binary string and a target fraction F, find the smallest starting position among substrings whose proportion of 1s is closest to F. | Medium7 | Prefix sumSorting | No attempts yet | 5s | 512 MB | Judgeable |
| Smoothing Window (Large)Given N, K and every window sum of a hidden integer sequence, find the smallest max-minus-min range among all integer sequences that match. | Medium7 | Binary searchMath+1 | No attempts yet | 5s | 512 MB | Judgeable |
| Hot Dog ProliferationSpread vendors sharing corners with pair splits that send one vendor east and one west, using the fewest moves so every corner holds at most one vendor. | Medium7 | MathGreedy+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Interesting Ranges (Small)Count subranges of [L, R] containing an even number of decimal palindromes, modulo 1000000007, for R up to 10^13. | Medium7 | MathCombinatorics+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Busiest railway segment (large)Given a tree and Q paths, count how many paths use each edge and report the edge with the maximum count, breaking ties by lexicographic order of endpoints. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Problem PreparationMaintain an array under point increments and decrements, and after each update answer the sum of ceil(t_i / k) for a given k. | Medium7 | MathPrefix sum+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Range XORMaintain an array under range xor updates and range xor queries, both on subarrays given by index bounds. | Medium7 | Bit manipulationSegment tree+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Decompose into a ProductGiven m as a product of n factors (n ≤ 500, each up to 1e9), count ordered n-tuples of positive integers whose product is m, modulo 1e9+9. | Medium7 | Number theoryCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Number lock 2Given two equal-length digit strings S and T, find the fewest moves to turn S into T where a move shifts any contiguous block of dials one step up or down modulo 10. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Moving Stones Around a CircleGiven stone counts a and b on a cycle of N positions, find the minimum number of moves to transform a into b, or report impossibility. | Medium7 | GreedyPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Secret LinesSum |Xa - Xb| * max(Va, Vb) over all pairs of members with given power and position. | Medium7 | SortingDivide and conquer+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Colorful Village 3For each query range of houses, report the highest number of times any single brightness value appears within that range. | Medium7 | Prefix sumSorting+1 | No attempts yet | 5s | 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 |
| Maximal SumFor each query value b_j, find the maximum sum of a contiguous segment of a whose elements are all at least b_j, or 0 if none exists. | Medium7 | SortingDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| FishCount contiguous subarrays whose sum is at least K. | Medium7 | Prefix sumDivide and conquer+2 | No attempts yet | 1s | 64 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 |
| Contiguous Subsequence XORCount contiguous subsequences of the given sequence whose bitwise XOR is less than K. | Medium7 | Bit manipulationTrie+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Integral PolygonsCount the diagonals of a convex polygon that split it into two pieces of integer area, given integer vertex coordinates. | Medium7 | GeometryMath+2 | No attempts yet | 2s | 256 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 |
| Chameleon SubstringGiven a string S, find the longest substring that is both a prefix and a suffix of S and also appears somewhere strictly inside S. | Medium7 | String matchingString+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Tree and Queries 2Answer path-cost and k-th-vertex queries on a weighted tree with up to 100,000 nodes and queries. | Medium7 | TreeBinary search+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Build a BoatSplit a simple polygon into the largest number of equal-area vertical sections, each of area at least C, and print the bulkhead x-coordinates. | Medium7 | GeometryPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| GondolasPlace G gondolas at integer offsets on a loop of period 2T to minimize the total wait of N skiers, where each skier boards the first departure at or after their arrival. | Medium7 | Dynamic programmingSorting+2 | No attempts yet | 5s | 512 MB | Judgeable |
| Bracket substring queriesFor each query substring, find the length of the longest balanced bracket subsequence within it. | Medium7 | Prefix sumString+2 | No attempts yet | 2s | 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 |
| Prefix and SuffixFor each prefix of S that is also a suffix, output its length and how many times it occurs as a substring. | Medium7 | String matchingPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Perfect ChoirGiven sorted starting notes for N singers, each measure moves one singer up and another down by one; find the minimum measures until all notes are equal, or -1 if impossible. | Medium7 | MathGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Strings and QueriesFor a string S, F(i) is the length of the longest common suffix of S and the prefix of S ending at position i; answer M queries for F(i). | Medium7 | StringString matching+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Permutation Descent CountsCount permutations of order N with exactly v descents, modulo 1001113, for up to 1000 queries with N at most 100. | Medium7 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Orchard DivisionFind the smallest axis-aligned rectangle anchored at one orchard corner that contains exactly half of N given tree coordinates. | Medium7 | GeometryPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Performance ReviewFor each employee, sum t_j over all descendants j whose rank r_j is lower than the employee's rank. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 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 |
| Combining RiceballsGiven a row of riceballs, merge equal adjacent pairs or equal pairs with one ball between them, and find the largest size reachable. | Medium7 | Dynamic programmingIntervals+2 | No attempts yet | 2s | 512 MB | Judgeable |
| The Hottest Piece of CheeseGiven two families of non-crossing cuts across a rectangle and points inside it, find the piece containing the most peppers. | Medium7 | GeometrySorting+1 | No attempts yet | 1s | 512 MB | Judgeable |
| BananasPlace a spiral-walking monkey on an infinite grid so every banana cell lies on its path, minimizing total steps walked. | Medium7 | GeometryImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| RivaFind two points on a left-to-right non-self-intersecting polyline whose allowed chord length is within L and maximizes the area between the chord and the polyline above it. | Medium7 | GeometryTwo pointers+1 | No attempts yet | 2s | 64 MB | Judgeable |
| Arranging HeapsDivide N ordered mining points into K groups, each group merging into one heap at its last point, minimizing total weighted distance moved. | Medium7 | Dynamic programmingDivide and conquer+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Christmas EveGiven n weighted warehouses on a line, choose k of them as teleporter sites so that moving every other warehouse's presents into a chosen site gives the least total weighted distance. | Medium7 | Dynamic programmingSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Blocks&BallsGiven a container with fixed blocks and balls inside, find the water level where water volume v fills the region below that height. | Medium7 | Binary searchGeometry+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Smallest Square 2Given N lattice points, choose an axis-aligned square with lattice corners containing at least K points strictly inside and minimize its area. | Medium7 | Binary searchSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| WolvesCount subsets of N sections, each holding at most one wolf, such that every given interval contains at least one chosen section, modulo 1e9+7. | Medium7 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hyobin the LiarGiven missiles landing on distinct cells in order, find the first missile after which no legal placement of k non-touching ships of length a survives. | Medium7 | Binary searchGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Drawing a PicturePaste the same N by M clipboard picture T times with its top-left corner at (i,i) for each second i, then count red, green, and blue pixels remaining. | Medium7 | MatrixMath+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Three PointsCount triples of points where the x coordinates increase and the y coordinates order as r < b < g. | Medium7 | SortingPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Sherlock and Permutation Sorting (Small)For every permutation of 1..N, find the maximum number of order-preserving chunks with all earlier-chunk values smaller than later ones, then sum f(p)^2 modulo M. | Medium7 | Dynamic programmingCombinatorics+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 |
| Remove One for the Greatest GCDRemove one number so the GCD of the rest is as large as possible, but that GCD must not divide the removed number. | Medium7 | Number theoryPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Apple MarketGiven a grid of apple inventories and rectangle requests with budgets, sell apples to maximize total money where each apple costs 1. | Medium7 | GreedySorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Professional NetworkGiven N people, each joinable when Kevin's current connection count reaches A_i or by paying B_i points, find the minimum total points to connect with everyone. | Medium7 | GreedySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Drawing a pictureColors cycle through cells of a row-major grid; each cell area is H_i times W_j. Report the total area covered by each color. | Medium7 | MathPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Venue Rental (Large)Given up to 3000 axis-aligned rectangles, find the total area of their union, counting overlaps once. | Medium7 | GeometrySorting+2 | No attempts yet | 5s | 256 MB | Judgeable |
| Faster SortingFor each MINRUN, simulate Timsort's run splitting and report the number of subarrays and the number of bad elements pulled in. | Medium7 | SimulationTwo pointers+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Good RectanglesPrecompute an answer table so each query asks how many all-zero subrectangles fit inside a given rectangle of an n by m binary grid. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 4s | 256 MB | Judgeable |
| Binary String ToggleApply U range-toggle operations to an all-zero binary string and print the lexicographically largest string among all U+1 intermediate states. | Medium7 | Prefix sumGreedy+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Gather at one pointFor each query [l, r], find the minimum sum of Chebyshev distances from the people l..r to a freely chosen point. | Medium7 | Prefix sumDivide and conquer+2 | No attempts yet | 5s | 512 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 |
| Tree VisitsMaintain a value X under increments of 2^C modulo 2^N, mark all nodes on each root-to-leaf walk, and report the count of distinct visited nodes. | Medium7 | TreeBit manipulation+2 | No attempts yet | 5s | 1536 MB | Judgeable |
| Gems (GEM)Given range-sum constraints modulo 10 on an array of N values each in [0,100], find the lexicographically smallest valid array or report -1 if the constraints conflict. | Medium7 | Union-findPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| AntsEach room of a weighted tree rooted at room 1 holds an ant with limited energy; for every ant, find the closest-to-root room it can reach moving toward room 1. | Medium7 | TreeDFS+2 | No attempts yet | 2s | 256 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 |