Skip to main content
OlympiadHQ

Browse · MathNet

Print

Macedonian Mathematical Olympiad

North Macedonia counting and probability

Problem

In a city of gnomes there are identical towers, each of which has stories, with exactly one gnome living on each story. Every citizen proudly wears a hat colored in one of possible colors and any two residents of the same tower wear differently colored hats. A pair of gnomes are friends if they wear hats of the same color, one of them lives on the -th story of his tower and the other one lives on the -st story of his tower. Determine the maximum possible number of pairs of gnomes that are friends.
Solution
Let us analyze the problem. There are towers, each with stories, so there are gnomes. Each gnome wears a hat of one of colors, and in each tower, all colors are present (since any two residents of the same tower wear differently colored hats).

A pair of gnomes are friends if: - They wear hats of the same color. - One lives on the -th story of his tower, and the other on the -st story of his tower (possibly in a different tower).

We are to maximize the number of such pairs.

Let us fix a color . In each tower, there is exactly one gnome with hat color on each story. So, for color , there are towers stories = gnomes with color .

For each color , consider the gnomes on the -th story in all towers. There are such gnomes (one per tower). Similarly, for the -st story. For each to , we can pair each gnome on the -th story with each gnome on the -st story, but only if they are in different towers (since in the same tower, the two gnomes have different colors).

But the definition says: "one of them lives on the -th story of his tower and the other one lives on the -st story of his tower". It does not require them to be in the same tower, and in fact, in the same tower, the two gnomes have different colors, so cannot be friends.

So, for each color , for each to , we can pair the gnome with color on the -th story of tower with the gnome with color on the -st story of tower , for all from to .

But to count the number of pairs, for each color , for each to , there are gnomes on the -th story and gnomes on the -st story, so possible pairs for each and each color .

But we must be careful: is it allowed to pair a gnome on the -th story of tower with the gnome on the -st story of tower for any ? Yes, as long as they have the same color, which is possible since every tower has all colors, and the gnome on the -th story of tower with color exists for every and .

But the problem asks for the maximum possible number of pairs. That is, we can assign the colors to the gnomes in the towers in any way, as long as in each tower, all colors are present (no two gnomes in the same tower have the same color).

Let us try to maximize the number of pairs. For each color , for each to , the gnome with color on the -th story of tower and the gnome with color on the -st story of tower can be paired as friends for all .

But the problem says "a pair of gnomes are friends if they wear hats of the same color, one of them lives on the -th story of his tower and the other one lives on the -st story of his tower". It does not specify that the towers must be different, but in the same tower, the two gnomes have different colors, so cannot be friends.

Therefore, for each color , for each to , the gnome with color on the -th story of tower and the gnome with color on the -st story of tower are friends for all from to .

But we must count the number of pairs. For each color , for each to , there are gnomes on the -th story and gnomes on the -st story, so pairs for each and each color .

But if we count all such pairs, we are counting each unordered pair twice (once as and once as ), unless the problem wants ordered pairs. But the problem says "a pair of gnomes are friends if...", so we count unordered pairs.

But in this construction, for each color , for each to , for each from to , the pair (gnome with color on -th story of tower , gnome with color on -st story of tower ) is a friend pair. But the pair (gnome on -th story of tower , gnome on -st story of tower ) and (gnome on -st story of tower , gnome on -th story of tower ) are different unless and and are swapped, but since in the same tower, the two gnomes have different colors, so cannot be friends.

Therefore, for each color , for each to , for each , the pair (gnome with color on -th story of tower , gnome with color on -st story of tower ) is a friend pair.

But the problem does not specify that the two gnomes must be in different towers, but in the same tower, the two gnomes have different colors, so cannot be friends.

Therefore, for each color , for each to , for each from to , , the pair (gnome with color on -th story of tower , gnome with color on -st story of tower ) is a friend pair.

But since the gnome with color on -th story of tower and the gnome with color on -st story of tower are distinct for , and the pair is unordered, we must count each pair only once.

Alternatively, for each color , for each to , there are gnomes on the -th story and gnomes on the -st story, so pairs for each and each color .

But since the gnomes are in different towers, and the colors are assigned so that in each tower, all colors are present, the maximum possible number of pairs is achieved when for each color , for each to , all gnomes on the -th story and all gnomes on the -st story are paired.

Therefore, the total number of pairs is:

Number of colors: Number of : (from to ) For each and color, pairs

Total number of pairs:

Therefore, the maximum possible number of pairs of gnomes that are friends is .
Final answer
999000

Techniques

Coloring schemes, extremal argumentsCauchy-Schwarz