Computer Science, asked by 20l240, 2 months ago

WQ2
Q-2
Report Error
Single File Programming Question
Marks : 8 Negative Marks : 0
Ram likes to play with numbers. Ram is given an array A with size N and
a number Z. Let's call a position i (1<i<N) valid if, after
increasing A; by Z, it would be greater than the sum of all other elements
in the array A.
Determine the number of distinct valid positions in his set of numbers.
Input format
The first line of each test case contains two space-separated
integers N and Z.
The second line contains N space-separated integers A1, A2, ..., AN
Output format
For each test case, print a single line containing one integer - the
number of valid positions.
Sample testcases
Input 1
Output 1
4 2
2 1 5 4​

Answers

Answered by amandeepsingh92288
3

Answer:

Write a program that, given an array A[] of n numbers and another number x, determines whether or not there exist two elements in S whose sum is exactly x.

Examples:

Input: arr[] = {0, -1, 2, -3, 1}

sum = -2

Output: -3, 1

If we calculate the sum of the output,

1 + (-3) = -2

Input: arr[] = {1, -2, 1, 0, 5}

sum = 0

Output: -1

No valid pair exists.

Similar questions