Comments

how do you handle security aspects

$$$2^0+2^1+...+2^{n-1}=2^n - 1$$$

May God bless you with a positive delta in tomorrow's round!

You need to make a simple observation:

In order for some $$$a_k$$$ to be divisible by some $$$a_i$$$ , $$$a_k \geq a_i$$$, so we need to choose the smallest element to be our $$$a_i$$$.

We then mark every multiple of $$$a_i$$$ as visited, this can be done in plenty of ways.

You will have a new array of visited and unvisited elements, you choose the minimum of the unvisited elements, let's call it $$$m$$$. Loop through the array, skip the visited elements, if one unvisited element is not multiple of $$$m$$$, the answer is No.

After giving it a thought, I was able to come up with this explanation, correct me if I'm wrong please.

Since each 2 points contribute to a game, (p1+p2+p3)/2 is the total number of games, and since we want to maximize the number of draws, we would consider all the games to be a draw.

in problem A, what's the intuition behind if p1 + p2 > p3 , then the answer is (p1+p2+p3)/2 ? , I wasn't able to prove it, all I did was guess it based on the test cases

Great idea, thank you for putting in the effort!

count how many $$$groups$$$ of consecutive zeros and ones are present, this can be done by checking $$$s[i] != [i+1]$$$.

Then you have 3 cases:

  • case 1 : you have more than 2 groups, the answer is always $$$groups-1$$$ ( you can always merge two groups together )

  • case 2 : you have exactly to groups, either the two groups are in the correct order, so the answer is $$$1$$$, or they are in reverse order, so the answer is $$$2$$$.

  • case 3 : you have exactly one group, so the answer is $$$1$$$.

Let's consider the first launch station.

When the station has its first launch, you can construct the following interval $$$I=[a, a+m]$$$, where $$$I$$$ represents all the moments in which a firework $$$x$$$ is visible.

Let's say $$$a=6$$$ and $$$m=4$$$, then $$$I=[6,10]$$$. If we want to count the maximum number of fireworks in this interval, it's clearly $$$\lfloor\frac{10}{6}\rfloor=1$$$, which is when $$$x=6$$$ (the next $$$x$$$ is $$$12\notin I$$$).

Now you do the same for the second launch station $$$b=7$$$, and the answer becomes $$$\lfloor\frac{10}{6}\rfloor + \lfloor\frac{11}{7}\rfloor= 2$$$.

Formally, $$$ans=\lfloor\frac{a+m}{a}\rfloor + \lfloor\frac{b+m}{b}\rfloor$$$ , which is $$$2 + \lfloor\frac{m}{a}\rfloor + \lfloor\frac{m}{b}\rfloor$$$

In a permutation of length n, the max number of steps to reach a cycle is always n.

example : 4 3 1 2

Here, whatever starting position you had, you will need to perform 4 moves to end up at the starting position

Thank you

Auto comment: topic has been updated by yariss (previous revision, new revision, compare).

You just use greedy. Find all divisors of n (except n itself) : - For each divisor i, "i" will represent the number of trucks used. - For each subarray of length i, find its sum. - Keep track of the maximum sum and the minimum sum - update the answer , such that ans = max(ans, maximum_sum — minimum_sum)