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,803 problems
| Title | Level | Topics | Solved | Time limit | Memory limit | Judge |
|---|---|---|---|---|---|---|
| Greedily Increasing SubsequenceGiven a permutation, repeatedly take the leftmost unused element larger than the previous pick, and report the resulting subsequence. | Medium4 | ArraySimulation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Homework Never Ends!Each minute either adds homework (value A, work time T) or nothing; a new task preempts the current one, and finished tasks are submitted at the minute they finish. Sum the values of tasks completed within N minutes. | Medium4 | StackSimulation+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Eeny MeenySimulate counting around a circle of kids with a rhyme length, removing one kid per round and assigning them to alternating teams. | Medium4 | SimulationImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| The New Year's BellGiven an N by M grid of who heard each bell ring, decide whether some distance thresholds R can produce exactly this pattern. | Medium4 | SortingGreedy+2 | No attempts yet | 1s | 512 MB | Judgeable |
| AntsGiven N integers, some negative or very large, find the smallest nonnegative integer that does not appear among the valid nonnegative values. | Medium4 | ArrayHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| AntennaGiven positions of houses on a line, pick the house position that minimizes the total distance to all houses, choosing the smallest such position on ties. | Medium4 | SortingMath+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Round TripA runner travels out and back along N courses given by their lengths; given total distance K, print which course the runner is on or about to enter. | Medium4 | ArrayPrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |
| PhotoshootGiven adjacent sums b_i = a_i + a_{i+1} of a hidden permutation of 1..N, reconstruct the lexicographically smallest permutation a. | Medium4 | Brute forceImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Arranging SoldiersGiven a sequence of N combat powers, find the minimum number of soldiers to remove so the remaining values are in strictly decreasing order. | Medium4 | Dynamic programmingArray+2 | No attempts yet | 1s | 256 MB | Judgeable |
| 2048Simulate a sequence of 2048 moves, applying gravity, merging equal tiles once per move, and adding merge values to the score. | Medium4 | SimulationImplementation+2 | No attempts yet | 2s | 512 MB | Judgeable |
| EmacsCount the non-overlapping, non-touching rectangles of '*' characters in an N by M grid. | Medium4 | ImplementationArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Maximum Subarray 2147483647Given a sequence of n integers, find the maximum possible sum of a contiguous subarray, choosing at least one element. | Medium4 | Dynamic programmingArray+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Coordinate CompressionFor each of N coordinates, output the number of distinct values smaller than it, which is its rank under coordinate compression. | Medium4 | SortingHash map+2 | No attempts yet | 2s | 512 MB | Judgeable |
| LadderGiven n sticks that can only be shortened, decide whether two can become length x and k others length y. | Medium4 | GreedySorting+2 | No attempts yet | 2s | 64 MB | Judgeable |
| Frog 2Each frog ends at (a,b) after c unit steps on the grid; find the initial lattice point, or NO, choosing the smallest x then y. | Medium4 | MathImplementation+2 | No attempts yet | 1s | 256 MB | Judgeable |
| Best PlaceGiven N points, find integer coordinates (X, Y) that minimize the sum of Manhattan distances from the point to every participant. | Medium4 | SortingMath+2 | No attempts yet | 1s | 512 MB | Judgeable |
| Checking Answers to TestGiven the correct answers and each student's answers, find every pair of students whose correct and incorrect answers each match on more than half of the questions. | Medium4 | Brute forceImplementation+2 | No attempts yet | 1s | 512 MB | Judgeable |
| DunesEach gust adds +x to l and then alternates signs up to r; answer m queries for the final height at given positions. | Medium4 | ArrayPrefix sum+2 | No attempts yet | 2s | 512 MB | Judgeable |
| Misha's ProductGiven n distinct integers, concatenate every ordered pair of them and report the sum of all these concatenations modulo 1e9+7. | Medium4 | MathArray+2 | No attempts yet | 1s | 512 MB | Judgeable |
| High-Rise BuildingsGiven the heights of N buildings in a row, find the maximum number of other buildings visible in a straight line of sight from any single building. | Medium5 | GeometryBrute force+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Lexicographically Largest SortGiven a distinct-integer array and a budget of at most S adjacent swaps, output the lexicographically largest array reachable within that swap budget. | Medium5 | GreedyArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Hongjun Programming ContestGiven school sizes, choose a team size k to maximize k times the number of schools whose size is divisible by k, requiring at least two such schools. | Medium5 | Number theoryMath+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Head TapsGiven N numbers arranged in a circle, count for each student how many other students' numbers it evenly divides using an efficient divisor-counting technique. | Medium5 | Number theoryMath+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Good NumbersGiven N integers, count how many of them equal the sum of two other numbers at two different positions in the sequence. | Medium5 | Two pointersArray+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Run, HongjunGiven N billboard intensities and a sight range M, output the maximum intensity within a sliding window of size 2M-1 for each valid position. | Medium5 | Sliding windowQueue+1 | No attempts yet | 2s | 256 MB | Judgeable |
| Fixed-Length Reversal SortGiven a permutation of up to 8 numbers, find the minimum number of fixed-length K reversals needed to sort it, or report impossibility. | Medium5 | BFSGraph+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Tangled Electric WiresGiven a matching between left and right poles, find the minimum number of wires to cut so no two remaining wires cross, which reduces to computing N minus the longest increasing subsequence. | Medium5 | Dynamic programmingBinary search+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Paper FoldingDecide whether a strip of N labeled cells can be folded so the stack reads 1 to N from top to bottom, checking labels against the shrinking strip's two ends. | Medium5 | Two pointersSimulation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| String ExchangeGiven a circular string of a's and b's, find the minimum number of swaps to make all a's form one consecutive block. | Medium5 | Sliding windowString+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Sejun and Sebi's WarGiven two armies whose weakest soldier dies each round (ties killing Sebi's soldier first), determine which side's soldier survives last. | Medium5 | GreedySimulation+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Counting Crossing EdgesGiven M cross edges between two labeled vertex sets of size N, count how many unordered pairs of edges cross each other. | Medium5 | SortingDivide and conquer+2 | No attempts yet | 2s | 128 MB | Judgeable |
| Making the Best TeamChoose 15 players for white and 15 for black from a list of up to 1000 players to maximize the total ability sum. | Medium5 | Dynamic programmingGreedy+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Chessboard in FENParse a chess position in FEN notation and count empty squares that are not attacked by any piece of either color. | Medium5 | SimulationMatrix+2 | No attempts yet | 1s | 32 MB | Judgeable |
| Making a PalindromeFind the minimum number of integers to insert into a sequence so it becomes a palindrome, using interval or LCS-based dynamic programming. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Power Strip SchedulingSimulate plugging devices into a strip with N outlets and, when full, evict the device whose next use is farthest away (or never used again), counting total unplugs. | Medium5 | GreedySimulation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Number GroupingGiven N integers, decide which pairs to multiply instead of add so that the resulting total sum is maximized. | Medium5 | GreedySorting+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Balanced LineupGiven fans sorted by x-coordinate with a gender bit each, find the longest contiguous segment that has an equal number of men and women. | Medium5 | Prefix sumHash map+2 | No attempts yet | 2s | 256 MB | Judgeable |
| Sorting the BookshelfFind the minimum number of single-book relocations needed to sort a permutation of N books into increasing order. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Lexicographically Smallest Valid SequenceGiven a permutation S, construct the lexicographically smallest permutation T where each element differs from the corresponding S element by at most 1. | Medium5 | GreedyArray | No attempts yet | 1s | 128 MB | Judgeable |
| Stacking BoxesSimulate stacking N axis-aligned boxes at given footprints using a 2D max-height map and report the final maximum height. | Medium5 | SimulationArray+1 | No attempts yet | 3s | 128 MB | Judgeable |
| Coin DistributionGiven several coin denominations with counts, decide for three test cases whether the coins can be split into two subsets of equal total value. | Medium5 | Dynamic programmingArray | No attempts yet | 2s | 128 MB | Judgeable |
| Jump Jump ChampionshipGiven an array, find the longest strictly increasing subsequence and output its length plus the indices of one such subsequence. | Medium5 | Dynamic programmingBinary search+1 | No attempts yet | 2s | 128 MB | Judgeable |
| OmokSimulate placing stones in given order on a 19x19 Gomoku board and find the first move that creates exactly 5 in a row (not 6+) for its color. | Medium5 | SimulationImplementation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Interval Containing the Most OthersGiven N intervals with unique endpoints, find the maximum number of intervals strictly contained inside a single interval. | Medium5 | SortingBinary search+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Bulbs and SwitchesGiven current and target bulb states, determine the minimum number of switch presses (each flipping a small neighborhood) needed, or -1 if impossible. | Medium5 | GreedySimulation+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Sum of Subarrays from Two ArraysCount pairs of contiguous subarrays, one from each of two arrays, whose sums add up to a given target T. | Medium5 | ArrayHash map+1 | No attempts yet | 2s | 64 MB | Judgeable |
| Building a BridgeGiven a grid of land and sea, find the shortest straight sea-cell bridge connecting two different islands. | Medium5 | BFSArray+1 | No attempts yet | 2s | 192 MB | Judgeable |
| Number of RectanglesGiven up to 5000 points, count axis-aligned rectangles whose four corners are all present among the points. | Medium5 | Hash mapCombinatorics+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Marbles in BoxesGiven two marble sequences and a pairwise score table, choose a sequence of pop/pop/pop-both operations to maximize total matched-pair score, using LCS-like DP with reconstruction. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Team FormationPartition an age-ordered score sequence into contiguous groups to maximize the sum of each group's max-minus-min score. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Sum of Three NumbersGiven up to 1000 distinct integers, find the largest set element expressible as a sum of three elements (repeats allowed). | Medium5 | Two pointersSorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Buying JewelsFor each of n rows pick a contiguous non-empty subarray maximizing summed total value, breaking ties by fewest jewels then lexicographically smallest index sequence. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 2s | 128 MB | Judgeable |
| Three SolutionsGiven up to 5000 distinct integers, find three distinct values whose sum is closest to zero, using sorting and two-pointer scanning. | Medium5 | Two pointersSorting+1 | No attempts yet | 1s | 256 MB | Judgeable |
| GemsGiven up to 100 diamond points on a grid, find the position of a fixed-size K by K square (axis aligned, within map bounds) that covers the maximum number of diamonds. | Medium5 | ArrayBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Rotating SushiFind the maximum distinct sushi types among any k consecutive plates on a circular belt, adding one bonus for a given coupon type if not already present. | Medium5 | Sliding windowHash map+1 | No attempts yet | 1s | 256 MB | Judgeable |
| Colored Paper 3Given up to 100 aligned black 10x10 squares on a 100x100 grid, find the maximum area axis-aligned all-black rectangle. | Medium5 | ArrayBrute force+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Corporate InvestmentAllocate exactly N integer units of money across M companies using given profit tables to maximize total profit, then output an allocation, a classic knapsack-style DP task. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Digital TVCompute the minimum button presses to move KBS1 to position 1 and KBS2 to position 2 in a channel list using arrow move and swap operations. | Medium5 | GreedySimulation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Viewership Popularity SurveyGiven N viewing intervals (possibly wrapping past midnight) over a day, use a difference array over seconds to answer Q sum-of-popularity queries divided by interval length. | Medium5 | Prefix sumArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Dongjun's GameGiven N level scores, find the minimum total decrease needed to make the sequence strictly increasing while all scores stay positive. | Medium5 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Array Not Divisible by ThreeRearrange an array so no two adjacent elements sum to a multiple of 3, or report impossibility. | Medium5 | GreedyMath+1 | No attempts yet | 1s | 128 MB | Judgeable |
| AvogadroGiven a 3xN table where row 1 is a permutation of 1..N, find the minimum number of columns to delete so the three rows can be made identical after sorting each row. | Medium5 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Popularity ListReconstruct the lexicographically smallest previous week's ranking consistent with UP/DOWN/SAME movement marks of this week's list. | Medium5 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Cut and PasteSimulate K cut-and-paste block moves on an N-line document and report the first ten resulting line values. | Medium5 | SimulationArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Complete the Sequence!Given a sequence known to fit a minimal-degree polynomial, use finite differences to extrapolate the next several integer values exactly. | Medium5 | MathImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Defense of a KingdomGiven tower positions that block whole rows and columns on a grid, find the area of the largest rectangle of cells left undefended. | Medium5 | SortingGreedy+1 | No attempts yet | 3s | 256 MB | Judgeable |
| BureaucracyGiven a sequence of declare and cancel operations forming a chain, determine which laws remain active where a law is active only if no active law cancels it. | Medium5 | SimulationImplementation+1 | No attempts yet | 3s | 256 MB | Judgeable |
| ComputersGiven a fixed replacement cost and arbitrary maintenance costs for owning a computer over any year range, find the minimum total cost to cover n years using dynamic programming. | Medium5 | Dynamic programmingArray | No attempts yet | 1s | 128 MB | Judgeable |
| Network ConnectionSimulate weighted union operations that always merge into the second cluster's center, and answer path-length queries to the current cluster center. | Medium5 | Union-findImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Non-negative Partial SumsGiven a cyclic array, count how many rotations make every prefix sum of the rotated sequence non-negative. | Medium5 | Prefix sumArray | No attempts yet | 3s | 128 MB | Judgeable |
| Bug HuntSimulate a small array based language line by line and report the first line where an out of range index or an unassigned array element is used. | Medium5 | SimulationImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| CounterattackTwo strikers advance in lockstep through n points, each step either dribbling or passing to the partner; find the cheapest route from a long pass at point 1 to a shot at point n. | Medium5 | Dynamic programmingArray+1 | No attempts yet | 1s | 256 MB | Judgeable |
| FlipperSimulate two-ended pile flips on a row of cards, then report the card number and orientation at queried positions. | Medium5 | SimulationImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Buying GasChoose the fewest gas stations to stop at so the car never runs out of gas over a trip of length d with tank range 10n. | Medium5 | GreedySorting+1 | No attempts yet | 1s | 128 MB | Judgeable |
| Frosh WeekGiven n distinct student numbers in a line, find the minimum number of adjacent swaps needed to sort them into increasing order. | Medium5 | SortingDivide and conquer+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Ferry Loading IIGiven car arrival times, ferry capacity n, and one-way time t, find the earliest finish time and the fewest one-way crossings to move all cars. | Medium5 | GreedyImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Splitting Teams FairlySplit N people into two teams differing in size by at most one so their total weight difference is minimized, then print both totals in increasing order. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Games R UsGroup users into equivalence classes by identical directory access sets, then report classes of size 2 or more. | Medium5 | Hash mapSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Rock SkippingFor each lake map, find the throw (start, skip distance) that maximizes count, then length, then start, then smallest distance, and print it. | Medium5 | Brute forceImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Overflowing BookshelfSimulate a fixed-width shelf through add (push books leftward) and remove events; at End list the surviving books left to right. | Medium5 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Board SillyGiven an 8x8 board of X and O pieces, list all legal moves for one player, where each piece moves exactly as many squares as pieces line its direction. | Medium5 | SimulationImplementation+1 | No attempts yet | 1s | 128 MB | Judgeable |
| The Turn of the ShrewEach child's code must differ from the bitwise OR of some male and female adult code; find the minimum Hamming distance over all pairs. | Medium5 | Bit manipulationBrute force+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Fuel StopsFind all valid starting cities in a circular tour where fuel supply matches demand, and the tank never goes negative. | Medium5 | GreedyPrefix sum+1 | No attempts yet | 2s | 128 MB | Judgeable |
| RailroadGiven two sequences, decide whether a target sequence can be formed by repeatedly taking the front car of either train; once one train empties, the rest follow in order. | Medium5 | Dynamic programmingTwo pointers+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ShufflingGiven a fixed permutation of N cards and a target order, find the minimum number of times to apply the permutation to reach the target, or -1 if impossible. | Medium5 | MathNumber theory+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Rotating RingsGiven square grids, decide whether each can be turned into row-major sorted order using only independent rotations of each concentric ring. | Medium5 | ArraySimulation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Walk Like an EgyptianStones fill an N by N grid along a spiraling quarter-circle path; find the number placed in the top-right cell. Multiple N values per input. | Medium5 | SimulationImplementation+2 | No attempts yet | 1s | 128 MB | Judgeable |
| ShopaholicGiven item prices, group them into triples so that the cheapest item in each triple is free, and maximize the total discount. | Medium5 | GreedySorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Rig PlacementGiven n oil fields, a per-field investment cap m, and a total budget B, pick an investment amount for each field so total oil is maximized. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Stimulus PackageChoose a subset of at most 20 projects within budget B whose combined jobs meet every yearly target, maximizing total infrastructure gain. | Medium5 | Brute forceImplementation+2 | No attempts yet | 5s | 128 MB | Judgeable |
| Overlap!Given each course's exam day and time slot and each student's course list, count students who have two or more finals that overlap in time. | Medium5 | ImplementationSorting+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Study DaysDistribute H study hours among n courses, each with 10 grade thresholds, to maximize the average grade point, rounded to two decimals. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| GerrymanderingSplit n precincts, each with P and Q vote counts, into two nonempty districts; find how many districts P can win (0, 1, or 2). | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| And the Winner IsEach ballot has one character per candidate; discard any ballot that marks more than one candidate in the same race, then report the top vote-getter (ties included) in every race, in input order. | Medium5 | ImplementationArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| BallsThere are n balls and n holes. Balls fall straight down from (i,h) to holes at (i,0). Placing exactly one obstacle (a segment between two integer columns) that tilts right redirects all balls in its column range to its right (lower) end; tilting left redirects them to its left (lower) end. For each orientation, maximize the total score over all valid placements (both orientations must be used, i.e., one obstacle of the specified tilt is mandatory, even if it reduces the total). Constraints n up to 3e5, c_i up to 1e9 in absolute value, so O(n log n) or O(n) required, answers in 64-bit. | Medium5 | ArrayPrefix sum+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Northwest WindCount pairs of islands where one can sail to the other moving only east or south (both coordinates monotone between the two points). | Medium5 | SortingPrefix sum+2 | No attempts yet | 1s | 256 MB | Judgeable |
| ImagineMaintain a 1024x1024 grid that starts as a checkerboard and process stickers plus rectangle queries for counts of each letter. | Medium5 | Prefix sumArray+2 | No attempts yet | 1s | 256 MB | Judgeable |
| JOIOI TowerGiven a string of J, O, I disks by increasing radius, find the maximum number of disjoint triples spelling JOI or IOI. | Medium5 | GreedyArray+1 | No attempts yet | 1s | 128 MB | Judgeable |
| FashionistaFor each day pick any clothing whose temperature range covers that day's high, maximizing the sum of absolute flashiness differences between consecutive days. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |
| Commute RouteCount monotone lattice paths from (1,1) to (w,h) that never turn at two consecutive intersections, modulo 100000. | Medium5 | Dynamic programmingArray+2 | No attempts yet | 1s | 128 MB | Judgeable |