Codeforces #665 Div-2

Distance and Axis basically in this question we have to place B between O & A such that |OB - AB| = k. We are given OA (n), OB = m (let). According to question we can derive a formula n - m - m = k &  simplify it as m = (n-k) / 2. 


Hence now we found out exact position of B. Now since we have OB (m) & AB (n-m), we can now find |OB - AB| (d), if this d matches with k then we found out the required position else we have to perform d-k steps.

 

The other cases are pretty simple & can be figured out by using pen & paper.

 

Solution 

 

 Related Articles : Must do questions for Competitive Coding

 

Ternary Sequence . In this question we can only maximize our sum by multiplying X2 & Y1, also we have to minimize Y2 using X0. At last minimize Y0 using X1, if are still left with X1 & Y2 then we are compelled to use both & decrease our sum.


Solution

 

  Other Articles : Kick start Web Scrapping

 

Mere Array

First step obviously will be to find minimum element from entire array. Now first thing which strikes that we can do GCD of this minimum element with any other element of array, the result will be minimum. If this condition holds true we can say minimum element is factor of that array element.

 

Now all those elements that turn out to be minimum we will replace them by -1 & store them some where else. Like for 4 3 6 6 2 9 elements, after GCD becomes -1 3 -1 -1 -1 9 & we store 4 6 6 2 some where else.

 

Now sort 4 6 6 2 it will become 2 4 6 6, at last place these numbers in place of -1. Finally if the resultant array became sorted the answer is YES else its NO.

 

Solution

 

 Must See Articles : Development, Data Structure, LeetCode

No comments:

If you have any doubt or suggestion let me know in comment section.

Powered by Blogger.