#C4128. Spending Pattern Validator
Spending Pattern Validator
Spending Pattern Validator
In this problem, you are given the daily spending amounts for a company over a week along with the total weekly marketing budget. The spending pattern is considered valid if it meets the following criteria:
- There must be exactly 7 spending values (one for each day).
- Each spending amount must be unique (i.e. no duplicates are allowed).
- The sum of the 7 spending values must equal the provided budget.
Your task is to process multiple test cases. For each test case, determine whether the spending pattern is valid. Output the string “VALID” if the pattern meets all criteria, otherwise output “INVALID”.
Note: All numeric comparisons should be done exactly. Make sure your solution reads from standard input and writes to standard output.
inputFormat
The input begins with an integer T, representing the number of test cases. For each test case, there are two lines:
- The first line contains 7 space-separated integers denoting the spending amounts for each day.
- The second line contains a single integer representing the total marketing budget for the week.
Input is read from standard input (stdin).
outputFormat
For each test case, output a single line containing either "VALID" or "INVALID" (without quotes) depending on whether the spending pattern meets the required conditions. The output should be written to standard output (stdout).## sample
6
1 2 3 4 5 6 7
28
1 2 2 4 5 6 7
27
1 2 3 4 5 6 8
28
1 2 3 4 5 6
21
1000 2000 3000 4000 5000 6000 7000
28000
0 0 0 0 0 0 0
0
VALID
INVALID
INVALID
INVALID
VALID
INVALID
</p>