Question Set 2
One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.
Pete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight.
The first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of the watermelon bought by the boys.
Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case.
There are people on a street (numbered through ). For simplicity, we'll view them as points on a line. For each valid , the position of the -th person is
It turns out that exactly one of these people is infected with the virus COVID-19, but we do not know which one. The virus will spread from an infected person to a non-infected person whenever the distance between them is at most . If we wait long enough, a specific set of people (depending on the person that was infected initially) will become infected; let's call the size of this set the final number of infected people.
Your task is to find the smallest and largest value of the final number of infected people, i.e. this number in the best and in the worst possible scenario.
Input
- The first line of the input contains a single integer denoting the number of test cases. The description of test cases follows.
- The first line of each test case contains a single integer
- The second line contains space-seperated integers
Output
For each test case, print a single line containing two space-separated integers ― the minimum and maximum possible final number of infected people.
Constraints
1 1 3 3 2 3
Link to the question-https://www.codechef.com/problems/COVID19Problem 3- Next Round (Easy)
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.A total of n participants took part in the contest ( n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.
The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.The second line contains n space-separated integers a 1, a 2, ..., a n (0 ≤ a i ≤ 100), where a i is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: a i ≥ a i + 1).
Output the number of participants who advance to the next round.
SAMPLE INPUT
6Link to the question-https://codeforces.com/problemset/problem/158/AProblem 4- Remove Element (Easy)Given an array nums and a value val, remove all instances of that value in-place and return the new length.
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
SAMPLE INPUT
Link to the question-https://leetcode.com/problems/remove-element/
Comments
Post a Comment