There are NN items in a shop. You know that the price of the ii-the item is AiAi. Chef wants to buy all the NN items.
There is also a discount coupon that costs XX rupees and reduces the cost of every item by YY rupees. If the price of an item was initially ≤Y≤Y, it becomes free, i.e, costs 00.
Determine whether Chef should buy the discount coupon or not. The chef will buy the discount coupon if and only if the total price he pays after buying the discount coupon is strictly less than the price he pays without buying the discount coupon.
Input Format
- The first line of input will contain a single integer TT, denoting the number of test cases. The description of the test cases follows.
- Each test case consists of two lines of input.
- The first line of the test case contains three space-separated integers — NN, XX, and YY.
- The second line contains NN space-separated integers — A1, A2,…, ANA1, A2,…, and AN.
Output Format
- For each test case, output
COUPON
if Chef should buy the discount coupon, andNO COUPON
otherwise.
Each letter of the output may be printed in either lowercase or uppercase. For example, the strings coupon
, CouPoN
, and COUPON
will all be treated as equivalent.
Constraints
- 1≤T≤10001≤T≤1000
- 1≤N≤1001≤N≤100
- 1≤X, Y≤1051≤X, Y≤105
- 1≤Ai≤105
//This code is written by Souvik Ghosh
import java.util.*;
public class discountCoupon {
public static void main(String[] args) {
//copy from here for codechef
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
int n = sc.nextInt();
int x = sc.nextInt();
int y = sc.nextInt();
int wd = 0;
int d = 0;
int array[] = new int[n];
for (int k = 0; k < n; k++) {
array[k] = sc.nextInt();
}
for (int j = 0; j < n; j++) {
wd += array[j];
if (array[j] > y) {
d += (array[j] - y);
}
}
if ((d + x) < wd) {
System.out.println("COUPON");
} else {
System.out.println("NO COUPON");
}
}
}
}