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,800 problems
TitleLevelTopicsSolvedTime limitMemory limitJudge
DictionaryFor each of the given 9-letter permutations of a through i, report its 1-based rank in lexicographic order.Easy3CombinatoricsMath+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
Turing machine halting in ten stepsSimulate a Turing machine for at most 10 steps on each query tape and report whether it reaches the halting state.Easy3SimulationImplementation+2No attempts yet1s256 MBJudgeable
Strategy GameDistribute J times R point values to players in turn order, sum each player's points, and find the highest scorer, breaking ties by last move.Easy3ArraySimulationNo attempts yet1s512 MBJudgeable
Formula 1 World ChampionGiven each driver's finishing place in every race, compute total points under several scoring systems and print the champion(s), breaking ties by listing all joint champions.Easy3ImplementationArray+1No attempts yet2s512 MBJudgeable
Card TradeGiven two sorted card piles, find the largest N such that Alice and Beatriz can each give away N cards of distinct kinds that the other does not own.Easy3Two pointersArray+1No attempts yet2s512 MBJudgeable
Peaks of a Musical LoopCount local maxima and minima in a circular sequence of samples where consecutive values differ and the first and last differ.Easy3ImplementationArray+1No attempts yet2s512 MBJudgeable
Averages in PlaceGiven N, print the one fixed N x N table whose row and column averages each land inside their own row and column, with -1 for N=2.Easy3ImplementationMath+2No attempts yet1s64 MBJudgeable
The Calculus of AdaGiven n values of a polynomial at evenly spaced inputs, find the degree of the minimal-degree polynomial and its value at the next input using finite differences.Easy3MathImplementation+2No attempts yet2s512 MBJudgeable
Hyper Rock-Scissors-PaperGiven each player's gesture in a 15-gesture rock-paper-scissors variant, find the single gesture that beats at least one shown gesture and loses to none, or report Draw.Easy3ImplementationArray+2No attempts yet8s512 MBJudgeable
Sum of Pairwise ProductsGiven N integers, sum the products of every pair of distinct positions.Easy3MathArray+2No attempts yet1s256 MBJudgeable
Small Weird MeasurementsCount the subarrays in which the signs of consecutive differences strictly alternate (length 1 counts, equal neighbours break it).Easy3ArrayImplementation+1No attempts yet2s512 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
Why Did the Cow Cross the Road 1Given observations of which side of the road each of 10 cows stands on, count how many times a cow changes sides between consecutive observations of that cow.Easy3ArrayImplementation+2No attempts yet2s512 MBJudgeable
Closest bus stopsGiven n distinct integer coordinates on a line, find the smallest absolute difference between any two and count how many pairs achieve it.Easy3SortingArray+1No attempts yet1s128 MBJudgeable
Salt and Pepper (Small)Given an M by N brightness matrix and odd window size W, output the median of every W by W window.Easy3ArraySorting+1No attempts yet1s512 MBJudgeable
Kim's DinerMaintain a list of pending orders under append, sort by (time, table), and delete-by-table commands, printing the list after each query.Easy3SimulationSorting+2No attempts yet2s256 MBJudgeable
High-End ArtworkStamps are pressed onto a paper in a given order; later presses overwrite earlier ones. Print the final grid, using '.' for untouched cells.Easy3SimulationArray+1No attempts yet4s512 MBJudgeable
Sickly YeongjeongMap each symptom to its medicine name, then for every query list output the matching medicines in order or YOU DIED if any symptom is untreatable.Easy3Hash mapImplementation+2No attempts yet1s512 MBJudgeable
Hyobin's TutoringMultiply N matrices in the given order and print the sum of the product's entries modulo 1,000,000,007, or -1 if the shapes do not line up.Easy3ImplementationMath+1No attempts yet1s512 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
Ttakji GameFor each of N rounds, compare two cards by counting stars, then circles, then squares, then triangles, and print which player wins or a draw.Easy3ImplementationArray+1No attempts yet2s512 MBJudgeable
CrammingGiven N chapters, each with a study time and a score, choose a subset whose total study time fits in T to maximize the total score.Easy3Dynamic programmingArray+2No attempts yet2s256 MBJudgeable
Reverse NonogramGiven a solved nonogram grid of '.' and 'X', print the run-length clues for every row and then every column.Easy3ImplementationSimulation+2No attempts yet2s512 MBJudgeable
Cezar's BlackjackGiven the values of N drawn cards summing to at most 21, decide whether to draw again based on how many remaining cards exceed the gap to 21.Easy3ImplementationMath+2No attempts yet1s64 MBJudgeable
Amusement AnticipationFor each sequence, find the starting position of the longest contiguous arithmetic run that ends at the last element.Easy3ImplementationArrayNo attempts yet2s512 MBJudgeable
Game of ThrownsTrack a token around a circle of children through clockwise or counterclockwise throws, undoing the last m throws on command.Easy3StackSimulation+1No attempts yet2s512 MBJudgeable
FitnessSimulate moves around 8 circularly numbered stations and print the visited sequence, marking it reject if fewer than 5 distinct stations appear or any station repeats.Easy3SimulationImplementation+2No attempts yet2s512 MBJudgeable
Musical ChairsSimulate musical chairs: each round every remaining player shifts M seats clockwise, the player at seat S is eliminated, and seats are renumbered until R rounds pass.Easy3SimulationImplementation+2No attempts yet2s512 MBJudgeable
Another Brick in the WallSimulate laying bricks in pile order across h layers of width w, and report whether every layer fills exactly before the pile runs out.Easy3SimulationImplementation+2No attempts yet2s512 MBJudgeable
Number PairsCount pairs of distinct values in a sequence that sum to a target K, where order does not matter and each element is used once.Easy3ArrayHash map+2No attempts yet2s512 MBJudgeable
Palindromic PasswordFor each six-digit number, print the closest six-digit palindrome, breaking ties by choosing the smaller one.Easy3ArrayBrute force+1No attempts yet3s512 MBJudgeable
Name CompatibilityInterleave two equal-length names letter by letter, replace each letter with its stroke count, then repeatedly sum adjacent digits (keeping the ones digit) until two remain.Easy3ImplementationSimulation+2No attempts yet1s512 MBJudgeable
Aron's Place in LineGiven the shirt colors of people in line, where each maximal run of equal colors is one group, find the position Aron occupies at the back.Easy3ImplementationString+2No attempts yet1s32 MBJudgeable
Olivander's wand boxesGiven N wand lengths and N box sizes, decide whether every wand can be paired with a distinct box whose size is at least the wand length.Easy3SortingGreedy+2No attempts yet1s64 MBJudgeable
Odd GnomeFor each group of unique IDs whose non-king elements increase by exactly one, output the 1-based position of the single out-of-order gnome.Easy3ArrayImplementationNo attempts yet2s512 MBJudgeable
Vera and ABCDEGiven a string of N letters from A to E, render the 5x3 pattern for each letter side by side and print the resulting 5 rows of 3N characters.Easy3ImplementationString+2No attempts yet2s512 MBJudgeable
Äventyr 1On a path 1 to N, vertices become active over time; after each activation, answer the distance from a query vertex to the nearest active vertex, or -1 if none exists yet.Easy3ArraySorting+2No attempts yet1s256 MBJudgeable
LifeguardsGiven N shifts, remove exactly one so that the total time covered by the remaining shifts is maximized.Easy3IntervalsBrute force+1No attempts yet2s512 MBJudgeable
Going Down 2Given N rows of three digits, move down choosing reachable cells and report the maximum and minimum possible sum of the digits passed through.Easy3Dynamic programmingArrayNo attempts yet1s512 MBJudgeable
Sorting numbers 5Read up to a million integers and print them in non-decreasing order, one per line.Easy3SortingArray+1No attempts yet10s128 MBJudgeable
Round and Round SnailA snail walks a clockwise square spiral from the origin, one cell per second; given n seconds, print its coordinates.Easy3ImplementationSimulation+2No attempts yet1s128 MBJudgeable
Multiply and DivideGiven three integers in fixed order, insert one multiplication and one division sign to maximize the value, evaluated left to right.Easy3MathImplementation+2No attempts yet1s128 MBJudgeable
Team Tic Tac ToeGiven a filled 3x3 board of letters, count single cows that own a full line and two-cow teams that together own a line with both letters present.Easy3Brute forceImplementation+2No attempts yet2s512 MBJudgeable
RouterSimulate a buffer of size N: packets arrive in order, 0 means one is handled and removed from the front, and a packet arriving with the buffer full is dropped.Easy3QueueSimulation+2No attempts yet1s512 MBJudgeable
Stroop EffectGiven sequences of two-digit word-ink codes, check whether each sequence satisfies the counts and the no-three-in-a-row rule for a valid Stroop test.Easy3ImplementationSimulation+2No attempts yet2s512 MBJudgeable
Twenty Thousand Leagues Under the SeaAmong N cages with given hole sizes, pick the largest hole whose area is under M and report its input index, or output Too small.Easy3ArrayBrute force+1No attempts yet2s512 MBJudgeable
Tide PodsScore each model person by the number of shared traits times their score, then output the largest minus smallest score. Multiple data sets follow, and each result gets its own header and trailing blank line.Easy3ArrayImplementationNo attempts yet2s512 MBJudgeable
Appalling ArchitectureGiven a grid of filled 1x1 boxes forming one grounded component, compare the center of gravity's x-coordinate with the leftmost and rightmost ground-contact x to say left, balanced, or right.Easy3ArrayMath+1No attempts yet1s512 MBJudgeable
Professor Na's Bad HandwritingReplace every 0 and 6 digit with 9 in each score, cap at 100, then print the integer nearest the average, breaking ties upward.Easy3ImplementationMath+1No attempts yet1s512 MBJudgeable
Paper FoldingGiven an N by N grid of numbers (N is a power of two), fold the paper in half repeatedly adding overlapping cells until one number remains; print it.Easy3ArrayMath+1No attempts yet1s512 MBJudgeable
Chaarshanbegaan at CafebazaarGiven up to 100 dart coordinates, score each by its distance from the board center and print the total score.Easy3MathImplementation+1No attempts yet2s512 MBJudgeable
TurnaroundsGiven the seconds when each team scored, report how many points fell in the first half and how many times the lead changed from strictly behind to strictly ahead.Easy3ImplementationSimulation+2No attempts yet1s512 MBJudgeable
Sugoroku and PiecesMove pieces forward one square on a 2019-square board, but block moves onto the goal or an occupied square, then report each piece's final position.Easy3SimulationArray+1No attempts yet2s512 MBJudgeable
Slimming PlanSimulate daily weight changes from the repeating D-day plan and report the day the weight reaches T, or output -1 if it never does.Easy3SimulationArray+1No attempts yet2s512 MBJudgeable
Teenage MutantCompare each of your k trait characters against all n ancestor strings at the same position, count positions where yours differs from every ancestor, and output that count over k.Easy3ArrayString+1No attempts yet2s512 MBJudgeable
Switches and LampsGiven N switches that each light some lamps and together cover every lamp, decide whether leaving out one switch still covers all lamps.Easy3ImplementationHash map+2No attempts yet2s512 MBJudgeable
Shell GameGiven N shell swaps and Elsie's guess after each swap, find the highest number of correct guesses she could make over all possible starting positions of the pebble.Easy3SimulationBrute force+2No attempts yet2s512 MBJudgeable
Phone Number CompatibilityInterleave two 8-digit phone numbers, repeatedly replace adjacent pairs by the units digit of their sum until two digits remain, and print the score with leading zeros.Easy3ImplementationSimulation+1No attempts yet2s256 MBJudgeable
Why Did APC Become a Subtask Contest?Given N problems each with an easy and hard difficulty and a solve limit K, find the maximum score Hyunjung can earn with skill L. Each problem's easy part is worth 100 and the hard part adds 40, and solving the hard part counts as one problem.Easy3GreedySorting+2No attempts yet1s512 MBJudgeable
Keyboard EventGiven key presses with keyboard number, time, and character, print the characters ordered by time, breaking ties by keyboard number.Easy3SortingImplementation+1No attempts yet1s256 MBJudgeable
I AM IRONMANSimulate N games: look up each opponent in a win/loss table, add W or subtract L (floored at 0), and report whether the score ever reaches G.Easy3SimulationImplementation+2No attempts yet1s256 MBJudgeable
Only Three!Count how many length-3 windows of a digit string are strictly increasing and are not extended to a run of four or more consecutive digits.Easy3StringImplementation+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
GerrymanderingSum precinct votes into districts, find each district's winner, compute lost and excess wasted votes per party, then output the overall efficiency gap.Easy3ImplementationMath+2No attempts yet2s1024 MBJudgeable
SticksGiven the heights of N sticks in a row, count how many sticks are visible when the row is viewed from the right, where a stick is visible only if it is strictly taller than every stick to its right.Easy3ArrayImplementation+2No attempts yet1s512 MBJudgeable
Lost LineupGiven each of Jimmy's friends' distance (number of people between them and Jimmy) from the front, reconstruct the original lineup with Jimmy first.Easy3ArraySorting+2No attempts yet1s512 MBJudgeable
Awkward PartyGiven a row of n language labels, find the smallest gap between two positions holding the same label, or n if all labels are distinct.Easy3ArrayHash map+1No attempts yet1s512 MBJudgeable
Mountain RangesGiven non-decreasing viewpoint altitudes along a trail, find the length of the longest run where each consecutive altitude increase is at most X, starting anywhere.Easy3ArrayTwo pointers+2No attempts yet0.1s512 MBJudgeable
Cat FoodGiven a binary picture rotated 90 degrees counterclockwise, check whether it equals the students' picture under the reverse rotation.Easy3ImplementationMatrix+2No attempts yet1s1024 MBJudgeable
Summer Hand FanFor each fan compute the price plus the sum C + 2C + ... + mC for the number of K-hour intervals fully completed during the walk Q, then output the cheapest fan index.Easy3MathImplementation+2No attempts yet1s1024 MBJudgeable
Black and WhiteGiven an n by n grid of B and W cells, check that every row and column is balanced and has no three cells of the same color in a row.Easy3ArrayImplementation+2No attempts yet1s512 MBJudgeable
Square Eye TestIn a grid containing exactly one colored square border with a one-cell gap at the middle of a side, report which side has the gap.Easy3ImplementationArray+2No attempts yet1s512 MBJudgeable
Cow GymnasticsGiven K rankings of N cows, count the pairs where one cow beats the other in every ranking.Easy3Brute forceArray+1No attempts yet1s512 MBJudgeable
Boxing Day Football AnalysisGiven the order of N goals scored by two teams, report the final score, the number of tied scores reached during the match, and the longest run of successive goals that flipped a deficit into a lead.Easy3SimulationImplementation+2No attempts yet1s512 MBJudgeable
BiodiversityGiven the species names of N animals, print the species that appears more times than all other species combined, or NONE.Easy3Hash mapImplementation+2No attempts yet3s512 MBJudgeable
IcebergsGiven N simple polygons, compute the total area and print its floor as an integer.Easy3GeometryMath+2No attempts yet3s512 MBJudgeable
PRIMFor each of T test cases, given an array of n integers, replace every element with the smallest prime that is at least that element, then print the sum.Easy3Number theoryMath+2No attempts yet2s512 MBJudgeable
CHROMGiven two parent permutations and two crossover points n and m, build the offspring by keeping parent 1's segment [n, m) in place and filling the rest from parent 2 in order.Easy3ArrayImplementation+2No attempts yet2s512 MBJudgeable
DISPERFor each professor, treat all student marks as one set, compute the variance of those marks, and report the professor with the highest dispersion to two decimals.Easy3MathImplementation+1No attempts yet2s512 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
Duplicate FilesGiven file names and unique IDs, keep the smallest ID for each distinct name and print the surviving IDs in increasing order.Easy3Hash mapSorting+1No attempts yet2s512 MBJudgeable
New Year and NamingGiven two cyclic string sequences, return the concatenation of the pair selected by each queried year index.Easy3ImplementationMath+2No attempts yet1s1024 MBJudgeable
Please Write the If Statements for MeGiven N titles ordered by increasing power upper bounds, print for each of M power values the first title whose bound is at least that value.Easy3Binary searchArray+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
SortingGiven a list of question difficulties, determine the minimum number of adjacent swaps needed to sort them into increasing order.Easy3SortingGreedy+1No attempts yet1s512 MBJudgeable
LunchBoxGiven N lunch boxes and each school's request ki, choose schools to satisfy fully (all ki boxes or none) so the count of served schools is maximized.Easy3GreedySorting+2No attempts yet0.5s512 MBJudgeable
Advertising on the FenceGiven n intervals over boards 1 to m, decide whether their union covers every board from 1 to m.Easy3IntervalsSorting+1No attempts yet2s512 MBJudgeable
Restoring the SequenceGiven n, m, and m board values, decide whether they are 1..n with exactly one number erased, and print that number.Easy3ImplementationMath+2No attempts yet1s512 MBJudgeable
Gold BarsGiven three bar weights with an even total, decide whether the bars already split evenly, or which single bar to cut in two so the pieces divide equally.Easy3MathImplementation+2No attempts yet2s512 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
Amateur AgronomistFind the longest contiguous segment of a flower row that does not contain three equal values in a row, and print its start and end indices.Easy3ArrayTwo pointers+2No attempts yet2s512 MBJudgeable
Good IntervalsGiven a set S of integers and a target n, count the number of intervals [A,B] with A<B that avoid all elements of S and contain n.Medium4MathArray+1No attempts yet2s128 MBJudgeable
Line UpReconstruct a line of N people (heights 1..N) given for each height how many taller people stand to its left, using reverse insertion.Medium4ArrayGreedy+1No attempts yet2s128 MBJudgeable
Sum of SubsequencesCount how many non-empty subsequences of up to 20 integers sum exactly to a given target S.Medium4BacktrackingBrute force+1No attempts yet2s256 MBJudgeable
Online Egg SalesGiven N eggs and M customers' maximum bid prices, pick the selling price (lowest if tied) that maximizes total revenue when all customers bidding at least that price buy an egg, capped at N sales.Medium4SortingGreedy+1No attempts yet2s128 MBJudgeable
Temporary Class PresidentGiven each student's class per grade for 5 grades, find the student who shared a class with the most distinct other students, choosing the smallest index on ties.Medium4ArrayBrute force+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
Platform Support PillarsGiven platforms with heights and horizontal spans, compute the total length of vertical support pillars placed slightly inside each platform's ends resting on the floor or a lower platform.Medium4SimulationSorting+2No attempts yet2s128 MBJudgeable