Question
Language in C Language : C Lili is now preparing the bonus point question for her Calculus class students. The bonus questions is explained below.
Language in C
Language : C
Lili is now preparing the bonus point question for her Calculus class students. The bonus questions is explained below. Lili will give data A, which contains N integers, to her class. Data A may not be sorted. Then, Lili will give them integer M. They will be asked to find the index from the data A such that if we sum all the elements from 1st index of A until Y th index, we will get a number that has the smallest difference with M and is less than or equal to M. Lili as a kind teacher prepares several questions to the class to make sure that all of her students will get the bonus point. Unfortunately, Lili has a lot of work to do. So, Lili asked you to find the answer of the question she had prepared before. You should give Lili the answer based on the problem description above.
Format Input : Input consists of one integer N, size of data A and followed by a line consists of N integers, which is the data A. The next line contains an integer Q, number of test case and for each test case, given M, the number described on the problem description.
Format Output : Output should be expressed in format Case #X: Y where X is the number of test case, and Y the biggest index based on the problem description above. If no value exists, just print -1 as the value of Y .
Constraints : 1 N 10^5 1 Q 30000 1 A i 10^9 1 M 10^15
Sample Input 1 (standard input) : 4 3 2 7 6 3 8 20 12 Sample Output 1 (standard output) : Case #1: 2 Case #2: 4 Case #3: 3
Sample Input 2 (standard input) : 5 2 9 5 5 7 6 11 12 16 17 22 3 Sample Output 2 (standard output) : Case #1: 2 Case #2: 2 Case #3: 3 Case #4: 3 Case #5: 4 Case #6: 1
DON'T COPY FROM OTHER PERSON ANSWER . THANKS !
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started