ICPC World Finals 2025

Problem H: Score Values

Solved by 66 teams.

First solved after 71 minutes.

Shortest judge solution: 1675 bytes.

Let’s first consider how to solve the problem for n = 1. For each digit from 0 to 8, we’ll use dynamic programming to determine the maximum number of times it can appear. We will run a separate DP for each possible number of digits, which will proceed left-to-right in the number, and will track the following state:

If n > 1 it is a little more tricky. It’s well-known that “large” scores can be achieved if and only if they are a multiple of the GCD of the p values. The threshold for being “large” is known as the Frobenius number, and while determining bounds is still an open area of research, it will not exceed the square of the largest p. Thus, we can separate the search into values less than 106 and those that are at least 106. The former can be treated as an integer knapsack problem, and the latter can be handled as for n = 1.