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 |
|---|---|---|---|---|---|---|
| RAMProcess files one by one; after each, count how many times a given letter appears in the last K characters seen so far. | Medium6 | ArraySimulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Big TableEach row of a huge table repeats a short digit period; answer rectangle-sum queries without materializing the table. | Medium6 | Prefix sumMath+2 | No attempts yet | 4s | 128 MB | Judgeable |
| The Walk to SchoolCount ordered pairs of grass cells where a fixed three-segment path (east, south, east) stays entirely on grass cells. | Medium6 | MatrixSimulation+2 | No attempts yet | 6s | 128 MB | Judgeable |
| Array CharacteristicMove one element to any position and maximize the weighted sum of A_i times its new index. | Medium6 | ArrayPrefix sum | No attempts yet | 2s | 512 MB | Judgeable |
| Water TankFind the smallest constant drain rate R so the tank never exceeds capacity C while inflow runs through n phases. | Medium6 | Binary searchPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| XORMaintain an array under range XOR updates and point queries, printing each queried element in order. | Medium6 | Binary searchPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Foehn PhenomenaAfter each range add to altitudes, report the wind temperature at spot N, where the total depends on the altitude differences between adjacent spots. | Medium6 | ArrayPrefix sum+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Hoof, Paper, Scissors (Gold)Given John's sequence of N gestures and at most K gesture switches, find the maximum number of games Bessie can win. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Ground DefenseHandle updates that add an arithmetic sequence of troops along a line of cities in one direction, and answer queries for a city's running total. | Medium6 | Prefix sumImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| PosterizeChoose k allowed red values so the weighted sum of squared distances from the d distinct intensities is minimized. | Medium6 | Dynamic programmingMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Ample Syrup (Large)Choose K of N cylindrical pancakes and stack them largest radius first to maximize exposed surface area, reported as a multiple of pi. | Medium6 | GreedySorting+2 | No attempts yet | 5s | 512 MB | Judgeable |
| CatsFind the minimum number of moves to reorder a line of cats, dogs, and lions so no cat is adjacent to a dog. | Medium6 | GreedyDynamic programming+2 | No attempts yet | 1s | 16 MB | Judgeable |
| Subarray XOR sumsFor a sequence, count how often each XOR value appears among all contiguous subarrays, then report the most frequent value, breaking ties by choosing the smallest. | Medium6 | Prefix sumBit manipulation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Pond CascadeGiven pond capacities and a common fill rate, compute the exact times when the lowest pond begins to overflow and when every pond is full. | Medium6 | SimulationMath+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Ducks in a RowFind the fewest flips needed so the string contains at least k maximal runs of D of length at least n. | Medium6 | Dynamic programmingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Dangerous DiscusGiven falling acid drops in columns, decide whether the single-pixel disc can stay at some height and cross without ever touching a drop. | Medium6 | Dynamic programmingSliding window+2 | No attempts yet | 2s | 512 MB | Judgeable |
| School PairingFor each query range, count pairs of positions whose skill grades sum to K. | Medium6 | Hash mapPrefix sum+1 | No attempts yet | 2s | 512 MB | Judgeable |
| RoofGiven N column heights, pick a peak position and height so the roof shape h_j = peak - |peakpos - j| is positive everywhere, minimizing total absolute changes. | Medium6 | ArrayPrefix sum+2 | No attempts yet | 1.5s | 128 MB | Judgeable |
| Haybale FeastPick a contiguous block whose flavor sums to at least M while minimizing the block's maximum spiciness. | Medium6 | Two pointersSliding window+2 | No attempts yet | 2s | 512 MB | Judgeable |
| My Cow Ate My HomeworkFor each prefix length K that the cow ate, compute the average after dropping the single lowest remaining score, and list every K that maximizes it. | Medium6 | ArrayPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Minimum editCompute the Levenshtein distance between two lowercase strings, using the fewest insert, delete, and replace operations to change A into B. | Medium6 | Dynamic programmingString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| LifeguardsFire exactly one of N given time intervals, then maximize the total length of time covered by at least one of the remaining intervals. | Medium6 | IntervalsSorting+1 | No attempts yet | 2s | 512 MB | Judgeable |
| Farmer Juan is a baristaMaintain a grid under range-add rectangle updates and point queries, answering each point query using only earlier updates. | Medium6 | Prefix sumMatrix+2 | No attempts yet | 2s | 512 MB | Judgeable |
| MinecraftGiven N rocks in a row with swing costs K_i, moving costs P, and budget T, find the maximum number of stones that can be collected. | Medium6 | GreedyBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Strawberry Carrot Watermelon Chamoe Melon GameGiven n words repeated in a b-beat cycle, find the turn on which a target word is shouted for the X-th time. | Medium6 | MathBinary search+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Hiding AcornsGiven K arithmetic-progression rules marking boxes, find the box number where the D-th acorn is placed, counting boxes in increasing order. | Medium6 | Binary searchPrefix sum+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Directory TraversalGiven a directory tree, choose a directory that minimizes the total length of all relative paths from it to every file. | Medium6 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Taming the HerdGiven a log of N counter readings, find for each possible number of breakouts the minimum number of entries that disagree with some valid breakout sequence that starts with a breakout on day 1. | Medium6 | Dynamic programmingImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Invader JinaPlace two poison sources on empty cells of an N by M grid so that the maximum Manhattan distance from any village to its nearest source is minimized. | Medium6 | Brute forceMath+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Capsaicin Tastes Good in SpringGiven N Scoville values, multiply each adjacent gap in sorted order by (2^k - 1) and sum modulo 1000000007. | Medium6 | SortingCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Junpyo's PebblesFind the longest contiguous segment containing at most B black pebbles and at least W white pebbles. | Medium6 | Two pointersSliding window+1 | No attempts yet | 1s | 512 MB | Judgeable |
| MeetingAdjust arrival times at cost 1 per second so that exactly K subordinates sit in an interval [0, X] with X a nonnegative integer; minimize cost. | Medium6 | Sliding windowSorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Tree and ColorsGiven a rooted tree with colored vertices and queries f(v,c) counting subtree vertices of color at most c, print the sum of all answers modulo 1e9+7. | Medium6 | TreeDFS+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hyunwook Is the Parenthesis King!!Given a string of parentheses, find the length of the longest contiguous substring that forms a correct parenthesis string. | Medium6 | StackString+2 | No attempts yet | 2s | 512 MB | Judgeable |
| XCorrGiven two sparse nonnegative sequences, sum the cross-correlation XCorr(t) over all shifts t in a query range. | Medium6 | Prefix sumMath+2 | No attempts yet | 2s | 512 MB | Judgeable |
| 1, 2, 3 Sum 6Count the compositions of n into parts 1, 2, and 3 that read the same forwards and backwards, modulo 1,000,000,009. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 512 MB | Judgeable |
| BracketGiven a bracket pattern with some fixed brackets and some dots, count the ways to fill the dots so the whole string is a balanced bracket sequence. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| LiarsGiven each person's claimed range for the truth-teller count, find the maximum possible number of truth-tellers within any consistent assignment. | Medium6 | Hash mapPrefix sum+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Rectangle EscapeA rectangle slides on a grid with walls; find the shortest sequence of unit moves taking its top-left cell from start to finish. | Medium6 | BFSPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Bitaro the BraveCount quadruples (i, j, k, l) with i<k and j<l such that grid cells (i,j)='J', (i,l)='O', (k,j)='I'. H, W up to 3000. | Medium6 | Prefix sumArray+1 | No attempts yet | 1s | 512 MB | Judgeable |
| Painting the Barn (Silver)Given N axis-aligned rectangles with coordinates in 0..1000, find the total area covered by exactly K of them. | Medium6 | Prefix sumArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Alice in the Digital WorldFind the maximum sum over subarrays whose minimum element equals m, given that the array and m are bounded by 26. | Medium6 | ArrayDivide and conquer+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Coloring PracticeCount how many 3x3 subgrids contain exactly i black cells for each i from 0 to 9, given up to 1e5 black cells on a huge grid. | Medium6 | Prefix sumHash map+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Why the Fox Climbed Information IslandCount triples of stars (s,t,u) with s.x < t.x < u.x and s.y > t.y < u.y, output the count modulo 1e9+7. | Medium6 | SortingBinary search+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Lemoine's ConjectureCount, for each odd N up to 10^6, the representations N = p + s where p is an odd prime and s is an even semiprime (product of two primes). | Medium6 | Number theoryPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Life GameSimulate Conway-style life on an N x M board for T steps using a (2K+1) square neighborhood with thresholds a and b, then print the final board. | Medium6 | SimulationImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Galactic RailwayAdd up to M edges between N galaxies one at a time; after each edge print the total planet count in the merged component. | Medium6 | Union-findGraph+2 | No attempts yet | 5s | 512 MB | Judgeable |
| StockFind the shortest subarray whose sum minus y times its length is at least Z and whose length times y is at most X, breaking ties by the latest start. | Medium6 | Sliding windowPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Candy DeliveryGiven N candies weighing 3 g or 5 g with sweetness values and a weight limit w, choose a subset to maximize total sweetness. | Medium6 | GreedySorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Bracket String and QueriesFlip one character per query and count how many prefixes of the query sequence leave the string as a correct bracket sequence. | Medium6 | StringPrefix sum+2 | No attempts yet | 0.5s | 512 MB | Judgeable |
| Count of Increasing SubsequencesCount the strictly increasing subsequences of length K in a sequence of N distinct values, reported modulo 1e9+7. | Medium6 | Dynamic programmingBinary search+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Saving the Ryan StatueChoose one integer point on each side of an N by N square to form a smaller rectangle, maximizing the total value of statues it covers, including those on its border. | Medium6 | ArrayPrefix sum+2 | No attempts yet | 3s | 1024 MB | Judgeable |
| Star TrekFind the minimum travel time from planet 1 to planet n, where you may switch ships at intermediate planets, paying a preparation time plus pace times distance for each leg. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Monument TourPick one eastbound row for the bus to travel; the cost is the horizontal distance across plus twice the vertical detours to visit every monument, and we minimize it. | Medium6 | MathPrefix sum+2 | No attempts yet | 1s | 512 MB | Judgeable |
| JOIOJIGiven a string of J, O, and I, find the longest contiguous substring with equal counts of all three letters. | Medium6 | Prefix sumHash map+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Gerrymandering 2For an N x N grid, try every valid 5-way district split defined by a reference point and two boundary lengths, and report the smallest difference between the largest and smallest district populations. | Medium6 | Brute forceSimulation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Beer MarathonGiven N beer booth positions and a fixed spacing K, choose an arithmetic progression of N positions (any start) minimizing the total absolute movement of the booths. | Medium6 | SortingGreedy+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Domino PredictionGiven XORs of consecutive domino numbers, answer queries for the XOR of positions x and y, or for the value at y when x holds d. | Medium6 | Prefix sumBit manipulation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| I Can Feel My Grade in the Flying Test PapersSplit an array into K contiguous groups; maximize the minimum group sum. | Medium6 | Binary searchGreedy+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Sculptural ProjectGiven a string of work and market days, cancel the fewest days so materials never run out and end at zero. | Medium6 | Dynamic programmingPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| FractionFor each query, print n decimal digits of a/b starting at the i-th digit after the decimal point, using the terminating representation when two exist. | Medium6 | MathNumber theory+2 | No attempts yet | 1s | 1024 MB | Judgeable |
| Penguin Fall Response CommitteeGiven a line of N blocks with break costs and one marked penguin position, find the minimum total cost to break blocks so the penguin's group falls off the line. | Medium6 | GreedyArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Milk VisitsGiven a tree with each node labeled G or H, answer queries asking whether the path between two nodes contains at least one node of a given label. | Medium6 | TreeDFS+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Splitting DNAGiven the lengths of N fragments in order, find the minimum total energy to split the original chain, where each cut costs the current chain length. | Medium6 | Dynamic programmingIntervals+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Just Long NecktiesFor each of the N+1 neckties, remove it and match the remaining N ties to N employees so the largest excess max(a-b, 0) is minimized. | Medium6 | GreedySorting+2 | No attempts yet | 2s | 512 MB | Judgeable |
| JJOOII 2Given a string of J, O, I and a level K, delete characters from the ends or middle to obtain K J's then K O's then K I's, minimizing middle deletions. | Medium6 | GreedyTwo pointers+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Money SharingGiven a sequence of resupplies and loan requests, decide which requests to approve so that the balance never goes negative while declining as few as possible. | Medium6 | GreedyHeap+2 | No attempts yet | 1s | 512 MB | Judgeable |
| JourneyCount binary strings of length N with no run of equal symbols longer than K, modulo 1e9+7. | Medium6 | Dynamic programmingCombinatorics+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Team AssignmentAssign each participant to team A (scoring their attack) or team B (scoring their defense) so the team sizes differ by at most k, maximizing the total. | Medium6 | GreedySorting+2 | No attempts yet | 0.7s | 256 MB | Judgeable |
| Multiple of N (1)Given 2N-1 numbers, find N of them whose sum is divisible by N, or report that none exists. | Medium6 | CombinatoricsPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Hyper Array and Hyper QueriesGiven a value for every cell of an 11-dimensional array, answer range-sum queries over axis-aligned 11-dimensional boxes. | Medium6 | Prefix sumArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Subarray Average of a SequenceCount the contiguous subarrays of a given sequence whose elements have an average exactly equal to K. | Medium6 | Prefix sumHash map+2 | No attempts yet | 1s | 256 MB | Judgeable |
| CryptographyGiven a permutation P of N distinct integers, output the 1-based rank of P among all permutations of its values, modulo 1,000,000,007. | Medium6 | CombinatoricsSorting+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Collecting MushroomsGiven a grid with mushrooms and sprinklers, count mushrooms covered by at least K sprinklers within Chebyshev distance D. | Medium6 | Prefix sumMatrix+2 | No attempts yet | 1s | 512 MB | Judgeable |
| SnailGiven a daily cycle of N moves that can climb or slide (never below 0), find the day and phase when the snail first reaches height H, or -1 -1 if it never does. | Medium6 | MathSimulation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Sequence TransformationGiven a sequence of non-negative integers, find the minimum number of single increments needed so that 1,2,...,h appear consecutively as a block, or report that it is impossible. | Medium6 | ArraySliding window+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Two PrefixesGiven strings s and t, count distinct strings formed by concatenating a non-empty prefix of s with a non-empty prefix of t. | Medium6 | StringString matching+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Jimin and Hansu's Orchard SplitGiven up to 50 weighted points on a plane, find a line avoiding all points that splits them into two groups minimizing the difference of their value sums. | Medium7 | GeometrySorting+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Equal-Length Subarray Sum DifferenceFor every subarray length k, find two non-overlapping equal-length subarrays whose sums differ the least, then report the k (largest on ties) with the smallest such difference. | Medium7 | Prefix sumSliding window+2 | No attempts yet | 5s | 128 MB | Judgeable |
| MedianGiven N temperature readings, compute the sum of medians of every contiguous window of length K using an efficient order-statistics structure. | Medium7 | Sliding windowHeap+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Sharp EyesGiven up to 20,000 arithmetic progressions forming a multiset, find the single integer with odd multiplicity using binary search on prefix parity. | Medium7 | Binary searchMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Parcel DeliveryGiven each parcel's destination branch along a line, find the minimum cost to deliver all parcels using per-distance trucks and fixed-cost multi-parcel helicopter trips. | Medium7 | Dynamic programmingSorting+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Number GameGiven a sequence of numbers, determine the winner of a two-player suffix-removal game where each player takes a suffix block ending at the current rightmost element and minimizes their own total sum, for three separate games with n up to 3000. | Medium7 | Dynamic programmingGame theory+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Collecting GemsGiven N gem values, find a contiguous subarray of length at least M that maximizes floor(1000*sum/length), using binary search on the average. | Medium7 | Binary searchPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Counting Submatrices with Divisible SumsCount contiguous submatrices of an N by M matrix (N,M up to 256) whose sum is divisible by K, requiring an efficient prefix-sum plus hashing technique. | Medium7 | Prefix sumHash map+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Sangbeom's MelancholyGiven daily moods, compute flower-giving intervals before each depressed run (2T days, or 3T for one chosen longest run) and find the maximum count of distinct covered days by optimally picking which longest run gets the 3T rule. | Medium7 | IntervalsGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Walking TrailFor up to 100,000 rectangle queries over 300,000 points, count how many points lie exactly on the boundary of each axis-aligned rectangle. | Medium7 | Prefix sumBinary search+1 | No attempts yet | 1s | 128 MB | Judgeable |
| ClotheslineFor each query time, compute the total overlapping area of given rectangles covered by an expanding Chebyshev-distance square of oil centered at the origin. | Medium7 | Prefix sumGeometry+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Median of a Contiguous SubsequenceCount odd-length contiguous subarrays of a permutation of 1..N whose median equals a given value B. | Medium7 | Prefix sumHash map+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Find the MultiplesCount index pairs (i,j) with a_i nonzero such that the decimal number formed by a_i...a_j is divisible by a given prime Q, for a pseudo-randomly generated digit sequence of length up to 1e5. | Medium7 | MathHash map+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Riding Roller CoastersGiven N coasters with fun a_i-(k-1)^2*b_i per ride and fixed ride times, answer Q queries for the maximum total fun within each time budget. | Medium7 | Dynamic programmingGreedy+2 | No attempts yet | 1s | 128 MB | Judgeable |
| HyperdromeCount substrings of S whose characters can be rearranged into a palindrome, where only the parity of each letter's count matters. | Medium7 | Bit manipulationPrefix sum+2 | No attempts yet | 2s | 128 MB | Judgeable |
| The Minotaur's LabyrinthFind the smallest empty square, avoiding the two corner cells, whose removal disconnects the top-left entrance from the bottom-right lair. | Medium7 | GraphBFS+2 | No attempts yet | 2s | 128 MB | Judgeable |
| The Banzhaf Buzz-OffGiven board members with distinct weights, count for each weight how many winning coalitions make a member with that weight a critical voter. | Medium7 | Dynamic programmingCombinatorics+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Lawrence of ArabiaCut at most M of the N-1 gaps in a line of weighted depots to minimize the sum of products over all still-connected pairs. | Medium7 | Dynamic programmingPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Largest SquareGiven an N by N grid with W bad cells listed explicitly, find the largest axis-aligned square containing at most L bad cells. | Medium7 | Binary searchPrefix sum+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Choosing the Final Die's Face ValuesEach test case fixes several dice and asks for the r face values of the last die so that m given sums appear with exactly the given counts, choosing the lexicographically smallest set. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Covered WalkwayCover all required points on a line with segments, where covering from x to y costs c plus (x - y) squared, minimizing total cost. | Medium7 | Dynamic programmingDivide and conquer+1 | No attempts yet | 10s | 128 MB | Judgeable |
| EstimationPartition an array into k contiguous sections, each replaced by one constant value, to minimize the total absolute error. Multiple test cases until 0 0. | Medium7 | Dynamic programmingDivide and conquer+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Value of a TriangleGiven up to 400 rows of a triangular grid of unit triangles, find the sub-triangle with the largest sum of unit values. | Medium7 | Dynamic programmingPrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |