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,177 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
ServerCount how many jobs from the front finish in request order before their total duration exceeds T.Easy1Prefix sumSimulationNo attempts yet1s256 MBJudgeable
Subin and the SequenceGiven the prefix averages of a sequence, recover the original sequence term by term.Easy1Prefix sumMathNo attempts yet1s32 MBJudgeable
Song ScoresGiven cumulative durations of N song scores, answer Q queries asking which score is being sung at a given time using prefix sums and search.Easy2Prefix sumBinary search+1No attempts yet2s128 MBJudgeable
Super MarioGiven 10 mushroom scores, pick a prefix sum closest to 100 (preferring the larger one on ties) as Mario's final score.Easy2ArrayBrute force+1No attempts yet1s128 MBJudgeable
Tetrahedral Stacks of CannonballsFor each of n queries, read the base side length and print the problem number, the side length, and the total cannonballs in a tetrahedral stack of that size.Easy2MathImplementation+1No attempts yet1s128 MBJudgeable
Magnificent MeatballsGiven a circular list of guest meatball counts, find the position k where the sum of positions 1 through k equals the sum of the rest.Easy2ArrayPrefix sum+1No attempts yet1s128 MBJudgeable
Hay ExpensesGiven N daily hay counts and Q ranges, output the sum of counts over each range from S to E inclusive.Easy2Prefix sumArrayNo attempts yet1s128 MBJudgeable
ParkFor each of up to one million heights in order, output the maximum height to its west and to its east, using its own height when no higher point exists.Easy2Prefix sumArrayNo attempts yet1s512 MBJudgeable
Shoe FactoryChoose the price p from 1 to N that maximizes the count of buyers willing to pay p times the margin p minus K.Easy2Prefix sumBrute forceNo attempts yet1s128 MBJudgeable
Negative People in Da HouseGiven each test case's sequence of entries and exits, compute the smallest initial occupancy that keeps the count nonnegative throughout.Easy2Prefix sumSimulationNo attempts yet1s256 MBJudgeable
Are we there yet?Given four distances between consecutive cities on a line, print the full 5x5 table of distances between every pair of cities.Easy2ArrayPrefix sum+2No attempts yet2s512 MBJudgeable
Tour de BINUSSum students over Ayu's left or right walk from x1 and count zero-valued rooms over Budi's walk from x2.Easy2ArrayPrefix sum+1No attempts yet1s512 MBJudgeable
∑|ΔEasyMAX|Given a sequence of tempos, answer queries that ask for the sum of absolute differences between consecutive values over a range.Easy2Prefix sumArray+2No attempts yet1s256 MBJudgeable
TrolGiven an array where A[i] is the digital root of i for i from 1 to 260, answer Q queries asking for the sum over a range [l, r].Easy2Prefix sumMath+1No attempts yet1s512 MBJudgeable
Lucky TicketFind the longest even-length substring of a digit string whose first half digit sum equals its second half digit sum.Easy3Prefix sumBrute force+2No attempts yet2s128 MBJudgeable
Sum of Numbers 2Given N positive integers and a target M, count contiguous subarrays whose sum equals M.Easy3Two pointersPrefix sum+1No attempts yet0.5s128 MBJudgeable
2D Array Range SumBuild a 2D prefix sum over an N by M grid and answer up to 10,000 rectangle sum queries in O(1) each.Easy3Prefix sumMatrix+1No attempts yet2s128 MBJudgeable
Temperature SequenceFind the maximum sum of any K consecutive elements in an array of N temperatures.Easy3Sliding windowPrefix sum+1No attempts yet1s128 MBJudgeable
Equal-Sum SegmentsSplit an array into contiguous segments with equal sums and output the smallest possible such common sum.Easy3Prefix sumGreedy+1No attempts yet1s128 MBJudgeable
Average SpeedTrack a car's speed changes over time and answer queries asking the total distance travelled up to a given elapsed time.Easy3SimulationImplementation+1No attempts yet1s128 MBJudgeable
Mad ScientistRecover a non-decreasing sequence of measurements from its cumulative counts P(j), the number of measurements at most j, for each j from 1 to k.Easy3ArrayPrefix sum+1No attempts yet1s128 MBJudgeable
HangoverFor each target overhang c, find the smallest n such that the harmonic sum 1/2 + 1/3 + ... + 1/(n+1) reaches c, and report n.Easy3MathImplementation+2No attempts yet1s128 MBJudgeable
Gold CoinsFor each number of days, add up the gold coins when the knight is paid N coins on each of N consecutive days.Easy3MathImplementation+2No attempts yet1s128 MBJudgeable
The TravelerGiven gaps between n towns and a walk of m east/west jumps, find the total distance covered, reported mod 100000.Easy3Prefix sumArray+2No attempts yet1s128 MBJudgeable
Maximum SumGiven n integers and a window size k, find the largest sum of any k consecutive terms.Easy3ArraySliding window+1No attempts yet1s128 MBJudgeable
Line of Best FitGiven n points in the plane, compute the slope and intercept of the least squares regression line and print each rounded to three decimals.Easy3MathImplementation+2No attempts yet1s128 MBJudgeable
Find the CowCount ordered pairs of indices (x, y) with x < y where an "((" starts at x and a "))" starts at y in a parenthesis string.Easy3StringPrefix sum+2No attempts yet1s128 MBJudgeable
ProfitsGiven a sequence of N daily profits, find the maximum sum over any contiguous stretch of days.Easy3ArrayDynamic programming+2No attempts yet1s128 MBJudgeable
Good GrassFind the 3x3 subgrid with the largest sum in a grid of milk values and report that sum with the upper-left corner, breaking ties by smallest row then column.Easy3ArrayPrefix sum+2No attempts yet1s128 MBJudgeable
Balancing Bank AccountsGiven transactions among travelers, compute each person's net balance and print the canonical chain of payments using prefix sums.Easy3Prefix sumHash map+1No attempts yet1s128 MBJudgeable
Trimmed and Corrected MeanGiven N judge scores and an integer K, sort the scores, then output the trimmed mean that drops K from each end and the corrected mean that replaces those extremes with the nearest kept value, both rounded to two decimals.Easy3SortingPrefix sum+2No attempts yet1s256 MBJudgeable
MillenniumGiven a birthdate in a fictional 10-month calendar with alternating 19 and 20 day months, find days until year 1000, month 1, day 1.Easy3MathImplementation+2No attempts yet1s128 MBJudgeable
FishingFind the starting day among the first N days whose window of k consecutive days contains the most rainy days, choosing the smallest index on a tie.Easy3Sliding windowArray+1No attempts yet1s1024 MBJudgeable
EquationsGiven sums of each number paired with the last number, plus the total sum, recover all N original numbers.Easy3MathImplementation+1No attempts yet1s1024 MBJudgeable
Ancient KeyboardSimulate a keyboard where each of up to 26 keys toggles an LED at two given times, and output the letter matching the LED count at each time step until all intervals end.Easy3SimulationImplementation+2No attempts yet1s128 MBJudgeable
Easy TradingGiven daily prices, compute moving averages over the last m and n days and print a buy or sell signal whenever the trend between them reverses.Easy3ArrayPrefix sum+2No attempts yet2s128 MBJudgeable
Big NumberFor each m up to 10^7, print the number of decimal digits in m factorial.Easy3MathNumber theory+1No attempts yet2s128 MBJudgeable
Passing CarsCount pairs of cars moving toward each other where an eastbound car stands west of a westbound car.Easy3Prefix sumArrayNo attempts yet1s128 MBJudgeable
Two TowersRemove the fewest blocks from the tops of two towers so the remaining towers have equal height.Easy3GreedyTwo pointers+1No attempts yet1s128 MBJudgeable
Cutting the TapeSplit the row of integers into two nonempty parts so the absolute difference of the two part sums is as small as possible.Easy3Prefix sumArrayNo attempts yet1s128 MBJudgeable
Consecutive GirlsFind the fewest boys to remove so that k girls stand side by side in a row of n boys and girls.Easy3Sliding windowPrefix sum+1No attempts yet1s128 MBJudgeable
CircuitsPick the most cables whose total battery voltage does not exceed their total wire tolerance.Easy3SortingGreedy+1No attempts yet1s128 MBJudgeable
New Year's Eve Party LogCount the fewest entries and exits to add so the guest count never drops below zero and ends at zero.Easy3GreedyPrefix sumNo attempts yet25s128 MBJudgeable
Range Sum QueryAnswer many inclusive range sum queries on a static integer list using precomputed prefix sums.Easy3Prefix sumArrayNo attempts yet1s128 MBJudgeable
Kri StringFind the length of the longest even-length contiguous substring of a digit string whose two halves have equal digit sums.Easy3Prefix sumBrute forceNo attempts yet1s256 MBJudgeable
Bitcoin ProfitsGiven share difficulties, pick the integer k of at least 1 that maximizes k times the count of shares at or above k, breaking ties toward the smaller k.Easy3SortingPrefix sumNo attempts yet2s256 MBJudgeable
ATMReorder N people by withdrawal time so the sum of all waiting-plus-service finish times is as small as possible.Easy3GreedySorting+1No attempts yet1s256 MBJudgeable
Counting Primes in a RangeCount the primes between m and n inclusive for each blank-line separated test case.Easy3Number theoryPrefix sumNo attempts yet1s256 MBJudgeable
Maximum Number of DivisorsYou answer each query with the largest divisor count among integers from 1 to N that are not multiples of P.Easy3Number theoryPrefix sumNo attempts yet1s256 MBJudgeable
Range Sum QueriesAnswer many range-sum queries over a static array by precomputing prefix sums and subtracting.Easy3Prefix sumNo attempts yet1s256 MBJudgeable
Range sum queriesAnswer many inclusive range-sum queries over a fixed list by precomputing prefix sums.Easy3Prefix sumArrayNo attempts yet1s256 MBJudgeable
Russian FlagChoose the two row boundaries for the white, blue, and red bands so the number of repainted cells is smallest.Easy3Brute forcePrefix sumNo attempts yet2s512 MBJudgeable
Fly SwatterFind the K by K placement that encloses the most flies in its strict interior and print the count with the winning border drawn.Easy3Prefix sumMatrix+1No attempts yet1s64 MBJudgeable
Breed CountingGiven the breed of each cow in a row, report the count of each of the three breeds inside every query interval.Easy3Prefix sumArrayNo attempts yet2s512 MBJudgeable
Building a House (Large)Find the area of the largest axis-aligned rectangle containing only grass or shrubs in a grid with fewer than 20 rock, water, or tree cells.Easy3Brute forcePrefix sum+1No attempts yet5s512 MBJudgeable
Household Ledger (Easy)Maintain a ledger over N days with point additions and range-sum queries, printing the sum of entries from day p to day q.Easy3Prefix sumArrayNo attempts yet1s512 MBJudgeable
Sweet part-time jobJunsu can work at most m consecutive days out of n days with given daily wages; find the maximum total pay for such a window.Easy3Sliding windowPrefix sum+1No attempts yet1s512 MBJudgeable
Range Sum QueriesGiven a fixed array and m range queries, print the sum of elements between two given indices for each query.Easy3Prefix sumArrayNo attempts yet2s512 MBJudgeable
Bitcoin investmentGiven a list of daily bitcoin prices, buy on one day and sell on that day or later to maximize the selling price minus the buying price.Easy3ArrayGreedy+1No attempts yet2s512 MBJudgeable
Thief of the Circular VillageCount the starting positions of a circular window of M houses whose total amount stays below K.Easy3Sliding windowPrefix sum+2No attempts yet1s256 MBJudgeable
Sum of Pairwise ProductsGiven N integers, sum the products of every pair of distinct positions.Easy3MathArray+2No attempts yet1s256 MBJudgeable
Diwali lightingsGiven a pattern S repeated infinitely and a range [I, J], count how many bulbs in that range are blue.Easy3MathPrefix sum+2No attempts yet5s512 MBJudgeable
Diwali lightings (Large)Given a pattern string repeated forever, count how many blue bulbs appear between positions I and J in the infinite sequence.Easy3MathPrefix sum+2No attempts yet5s512 MBJudgeable
Why Did the Cow Cross the Road 5Given N traffic lights with B known broken positions, find the minimum number of broken lights to repair so that some K consecutive lights all work.Easy3Sliding windowArray+2No attempts yet2s512 MBJudgeable
Riemann Sum Offset (Small)For a linear polynomial, find the offset epsilon in [0, dx] that makes the Riemann sum equal the exact integral, or print -1.Easy3MathImplementation+2No attempts yet1s512 MBJudgeable
Mun, Hong, AnEach secretary adds one step to every stone in one direction from the start. Count total steps per stone modulo 3, then split P by the final blue, red, and green counts.Easy3ImplementationPrefix sum+2No attempts yet2s256 MBJudgeable
Sum GameGiven two length-N sequences of daily scores, find the largest K where the prefix sums of both sequences are equal.Easy3Prefix sumArrayNo attempts yet1s512 MBJudgeable
Progressive ScrambleEncrypt a message by cumulative sums of symbol values mod 27, and decrypt by inverting the same recurrence.Easy3ImplementationMath+2No attempts yet2s512 MBJudgeable
Predictable QueueGiven N task times and M time limits T, print how many tasks are processed first in order before their prefix sum exceeds T.Easy3Prefix sumBinary searchNo attempts yet1s512 MBJudgeable
Server RoomAir rises one unit per minute from the bottom of an N x N grid of stacked computers; find the earliest minute when at least half of all computers are cooled.Easy3SortingBinary search+2No attempts yet1s256 MBJudgeable
What if a car takes the side of its owner, Kim Pyojun?For each window length k from 1 to N, find the starting index of the length-k subarray with the largest standard deviation, breaking ties by the smallest index.Easy3ArrayPrefix sum+2No attempts yet1s512 MBJudgeable
You Have To Solve This One!Sort the array, then answer range-sum queries over the sorted sequence efficiently.Easy3SortingPrefix sum+1No attempts yet1s512 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
PolynomialGiven the coefficients and degrees of a polynomial in descending order, evaluate it at x using Horner's method and print the result modulo 1e9+7.Easy3MathImplementation+2No attempts yet1s1024 MBJudgeable
LabelsGiven the difference sequence D of an unknown sequence A with values in [1, N], output A if it is uniquely determined, otherwise -1.Easy3ArrayImplementation+2No attempts yet2s1024 MBJudgeable
Maximum ProductSplit the array after one index so the product of the two part sums is maximized, and print that index.Easy3Prefix sumArray+2No attempts yet2s512 MBJudgeable
Time ManagementGiven tasks with durations and deadlines, find the latest single start time so that all tasks scheduled back to back meet their deadlines, or report -1 if impossible.Medium4GreedySorting+1No attempts yet2s128 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
Flammable Railway 997Given fireproof material amounts between train cars and a starting fire location, compute the time step when a target car explodes, or report it never does.Medium4Prefix sumSimulation+2No attempts yet2s128 MBJudgeable
Overlapping SegmentsGiven N line segments on a number line, compute the maximum number of segments that overlap at any single point, not counting endpoint-only contacts.Medium4IntervalsSorting+2No attempts yet2s256 MBJudgeable
Sum of Numbers 4Count the number of contiguous subarray sums of an array that equal a given target K, using prefix sums and a hash map.Medium4Prefix sumHash map+1No attempts yet2s128 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
Post OfficeGiven villages with positions and populations on a line, find the point minimizing total weighted distance, choosing the smallest position on ties.Medium4SortingPrefix sum+1No attempts yet2s128 MBJudgeable
Collecting JewelsGiven N values in a line, find the maximum sum of a single contiguous run of length at least M taken once.Medium4Prefix sumDynamic programming+1No attempts yet2s128 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
Post OfficeGiven village coordinates and resident counts, find the smallest position minimizing total weighted distance to all residents (weighted median).Medium4SortingPrefix sum+1No attempts yet2s128 MBJudgeable
Guitar LessonSplit an ordered array into M contiguous groups so the maximum group sum is as small as possible, using binary search on the answer.Medium4Binary searchGreedy+1No attempts yet2s128 MBJudgeable
Sum of DistancesGiven n points on a line, compute the sum of absolute distances over all ordered pairs efficiently using sorting and prefix sums.Medium4SortingPrefix sum+1No attempts yet1s128 MBJudgeable
FireflyGiven alternating stalagmite and stalactite lengths in a cave, find the flight height destroying the fewest obstacles and how many heights tie for that minimum.Medium4Prefix sumArrayNo attempts yet1s128 MBJudgeable
DownloadGiven download times and playback durations of sequential song pieces, compute the earliest start time so playback never stalls waiting for a piece.Medium4GreedyPrefix sum+1No attempts yet1s128 MBJudgeable
The RiddleFind the minimum prefix length of a coin sequence so that all values from 1 to K are achievable as subset sums, using the classic greedy reachable-range extension, or report -1.Medium4GreedyArray+1No attempts yet1s128 MBJudgeable
Divisible Contiguous SubarraysCount contiguous subarrays whose sum is divisible by a given d, using prefix sums modulo d and counting equal remainders.Medium4Prefix sumHash map+1No attempts yet1s128 MBJudgeable
KnittingGiven a starting stitch count, a row total, and a repeating pattern of row change values, compute the sum of all row stitch counts for each project until the 0 0 0 terminator.Medium4MathPrefix sum+1No attempts yet1s128 MBJudgeable
sqrt log sinPrecompute x_i for all i up to 10^6 using the given recurrence with floating point floors, then answer each query modulo 10^6.Medium4Dynamic programmingMath+2No attempts yet1s128 MBJudgeable
Baskets of Gold CoinsGiven the total weight of coins drawn with counts 1..N-1 from N baskets, find which basket holds the lighter coins.Medium4MathBrute force+2No attempts yet1s128 MBJudgeable
Frodo SequenceGiven repeated values of n less than 2^31, print the n-th term of the sequence defined by Fro_n = Fro_{n-1} + Fro_{n-2} - Fro_{n-3}.Medium4MathDynamic programming+2No attempts yet1s128 MBJudgeable
Planet ExplorationGiven a grid of jungle, sea, and ice cells, answer many rectangle queries by counting how many cells of each terrain type fall inside.Medium4Prefix sumArray+2No attempts yet1s256 MBJudgeable
GiftGiven each friend's item price and shipping cost and one coupon that halves a single item price, find the most gifts buyable within budget B.Medium4SortingGreedy+2No attempts yet1s128 MBJudgeable
Haybale StackingAdd one bale to every stack in each given range, then report the median height among all N stacks.Medium4Prefix sumArray+2No attempts yet1s128 MBJudgeable
Music NotesGiven note durations that divide a timeline into consecutive intervals, answer queries asking which 1-based note covers a given time. Use prefix sums and binary search.Medium4Prefix sumBinary search+2No attempts yet1s128 MBJudgeable