We answer will be n/5 if n%5==0 and if it's not 0 means remainder can be 1,2,3,4 which can be done in 1 step so, the output will be n/5+1.
Solution Problem A
This one is a simple brute force problem, we will construct our string with numbers. After construction, we just have to print the n-th element of the string.
Solution Problem B
You need sort the array and find the max of 2 occurrences and max of 3 occurrences from the array, then subtract the maximum with the total sum to get the minimum sum.
Solution Problem C
You simply need to check if any row has 0 in it and find the largest consecutive such row.
Solution Problem D
You should check two cases for YES:
1.x mod s = t mod s and t ≤ x 2.x mod s = (t + 1) mod s and t + 1 < x
Solution Problem E
It is obvious that if there is a pair of points (xi,yi) and (xj,yj) such that xiyj then the answer is "NO". It means that if the answer is "YES" then there is some ordering of points such that xi1 ≤ xi2 ≤ ... ≤ xin and yi1 ≤ yi2 ≤ ... ≤ yin because we can only move right or up. But what is this ordering? it is just sorted order of points (firstly by xi then by yi).
So we can sort all points, check if this ordering is valid and traverse among all these points. For each k from 2 to n firstly do xik − xik − 1 moves to the right then do yik − yik − 1 moves to the up (because this order minimizing the answer lexicographically). Time complexity: O(nlogn) or O(n^2).
Solution Problem F