|
0
how do you handle security aspects |
|
+6
$$$2^0+2^1+...+2^{n-1}=2^n - 1$$$ |
|
0
May God bless you with a positive delta in tomorrow's round! |
|
0
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. |
|
0
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. |
|
0
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 |
|
On
no_lie →
Introducing cses-enhancer: An extension for CSES problemset to add notes and mark tasks as favorite, 2 years ago
+1
Great idea, thank you for putting in the effort! |
|
0
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:
|
|
0
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$$$ |
|
0
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 |
|
+4
Thank you |
|
0
Auto comment: topic has been updated by yariss (previous revision, new revision, compare). |
|
0
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) |