Spring 26 - Learn Division April 10

Welcome to another week of competitive programming of Spring 2026! Today’s problem-solving session will feature a mixed set of problems covering implementation, greedy strategies, and dynamic programming.

But first, if this is your first time ever in one of our competitive programming sessions, please see our introduction guide to get started. Once you’re done, feel free to come back here.

To make the most out of your experience in these sessions you should read the introduction and then attempt to solve the problems one by one, i.e. don’t try working on B before solving A, C before solving A, etc. You don’t have to solve all the problems, you will be learning something even if you only try to solve a single problem.

Feel free to work together with a friend or two, this is supposed to be a collaborative environment. Also, if you are stuck or have questions, don’t keep them to yourself! Talk to other people! If you are not sure who to talk to, ask on discord.

Introduction

Today’s problems are a mix of different topics and difficulties. The first few problems are more straightforward and focus on careful implementation and greedy reasoning. The latter problems require more creative thinking, including dynamic programming.

I recommend you start by reading problem A and think about how you’d go about solving it. If you are stuck or don’t really know what to do, start by reading the hints below. If you are still stuck ask for help! Once you have an idea of what to do, try to implement a solution. Test it with the sample test cases and try to submit (you can submit as many times as you want). Once you get A accepted, progress to B, then C and so on.

Problem A. Einstein’s Calculator - Hints

You can find the problem description here. Read it and then come back here.

We want to maximize the value of an expression formed by placing operators between the numbers. Think about which operator generally gives the largest result when combining two positive numbers.

Problem B. Snailography - Hints

You can find the problem description here. Read it and then come back here.

This is a pure implementation problem. You need to place the letters of a message into a grid in a spiral pattern starting from the center, then read the grid row by row.

The main challenge is organizing your code in a clean way. It’s easy to overcomplicate a solution and end up with really messy code.

Problem C. We Want You Happy! - Hints

You can find the problem description here. Read it and then come back here.

This is a simulation problem. Process customers in order, keeping track of when the teller becomes free. For each customer, check whether they would still be waiting when the teller is available. If the customer’s patience runs out before the teller is free, they leave and the teller doesn’t spend any time on them. Otherwise, the customer is processed and the teller’s free time is updated accordingly.

Problem D. Faking Data - Hints

You can find the problem description here. Read it and then come back here.

We need to make the signal follow a strict alternating pattern using only decrease operations. Since there are two valid patterns (up-down-up-down or down-up-down-up), try both and take the minimum.

For a given pattern, think greedily: process the signals from left to right and figure out the minimum amount you need to decrease each signal so it satisfies the required strict inequality with its neighbor. Be careful about the direction of the inequality at each position.

Problem E. Bag Balancing - Hints

You can find the problem description here. Read it and then come back here.

This is a classic partition problem: can we split the items into two groups of equal total weight? First, note that if the total weight is odd, the answer is immediately “no”.

If the total weight is even, we need to determine if there’s a subset of items that sums to exactly half the total. This is a subset sum problem, which can be solved with dynamic programming. Use a boolean DP array where dp[j] indicates whether it’s possible to achieve a sum of j using some subset of the items. Start with dp[0] = true and update for each item.