Question

C Programming Language Problem Title: Jojo’s Hardest Problem (?) Jojo is enjoying his vacation with his...

C Programming Language

Problem Title: Jojo’s Hardest Problem (?)

Jojo is enjoying his vacation with his family. Suddenly an instant message came in.
Apparently there is a message from Lili :
”Jojo, don’t forget to check the forum. Who knows if there is an assignment before the exam”

Jojo finally took the time to check the discussion forum and sure enough, there were some
assignments given to his class. He immediately told his classmates.
Jojo finds out one difficult problem for himself as follows. Given an array contains N
elements and also given an integer M. You need to find a value of a function f(x, k)
so that the function has value as maximum as possible but still less than or equal to
M. Value of k is arbitrary as the value less than or equal to N. The function f(x, k) is
expressed as below.

f(x, k) = A[x] × k + A[x + 1] × (k − 1) + ... + A[x + k − 1] × 1

Help Jojo to get the right final answer.

Format Input

Input consists of an integer T that indicates the number of test case. Then, 3 lines follow.
The first line contains an integer N as the number of elements in array. The next one is
describing the value N elements A[i] in the array and followed by an integer M on the
third line.

Format Output

Output should be expressed in format ”Case #X: Y ” - X is the number of the test case,
and followed by Y , the maximum value of function f(x, k) such k arbitrary value that
less than or equal to N for Xth case.

Constraints

• 1 ≤ T ≤ 100
• 1 ≤ N ≤ 100000
• 1 ≤ A[i] ≤ 1000000
• 0 ≤ M ≤ 1000000000000000000

Sample Input & Output (standard input & output)

2

5

6 1 3 4 6

10

Case #1: 10

5

1 2 3 4 5

14

Case #2: 13

Explanation
For test case 1, the maximum result is

f(3, 2) = 3 × 2 + 4 × 1 = 10.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In the EXPLANATION part(LAST STATEMENT) of the question, it will be f(2,2). Other than that if you face any problem let me know in COMMENTS.

Add a comment
Know the answer?
Add Answer to:
C Programming Language Problem Title: Jojo’s Hardest Problem (?) Jojo is enjoying his vacation with his...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C Programming Language Problem Title: Discount Jojo is browsing the internet while suddenly he sees an...

    C Programming Language Problem Title: Discount Jojo is browsing the internet while suddenly he sees an ad about the new cafe. The promotion is if the price of an item is N dollars, then you can buy the second item for half the price, the third item for a quarter of the original price, and so on, but if it becomes less than M dollars, then you have to pay M dollars. He wonders how much he has to pay...

  • C Programming Language Problem Title: Introduction to Computer Vision Jojo is an outstanding student who is...

    C Programming Language Problem Title: Introduction to Computer Vision Jojo is an outstanding student who is currently pursuing his Computer Science degree. In one of his Computer Vision lectures, his lecturer tackled a topic about binary thresholding. For simplicity, binary thresholding is an image filtering method used to separate low val- ued pixels (dark) from high valued pixels (bright). Each pixels in an image is classified as low or high based on a certain threshold K. If a pixel Pij...

  • C language Thank you Jojo is going to a restaurant. There are N foods listed in...

    C language Thank you Jojo is going to a restaurant. There are N foods listed in the menu, and the items are sorted increasingly based on its price. Now Jojo is wondering how many foods are there with price P. As the number of food in the menu can be a lot, Jojo will need your help to answer his questions. Jojo knows you can count really fast, so he will give you M questions. Format Input Input begins with...

  • Write in C language . Thank you Count Sheep Jojo is having problem to sleep at...

    Write in C language . Thank you Count Sheep Jojo is having problem to sleep at night. He can't fall asleep and it makes him feel tired every day. Having this problem, Jojo told his friend Bibi, and Bibi advised him to do sheep counting while he tries to sleep. Jojo decided to try using this trick for N nights, to test its effectiveness. Jojo realized that he would fall asleep if he imagined a total of 10 white sheep....

  • C Programming Language Problem Title: Introduction to Database Database is a structurized method for data storage...

    C Programming Language Problem Title: Introduction to Database Database is a structurized method for data storage and perform operations related to the data. There are Some simple operations that can be done by a database are Insert, Alter, Delete, and Query. There are N different integers stored. You are asked to create a database where you can carry out the following 4 operations : 1. I X - this operation is insert operation, inserting X to the database. 2. A...

  • write in C language Decoration Lights Jojo is currently working in an office as a security....

    write in C language Decoration Lights Jojo is currently working in an office as a security. Every night, after everyone returned home, he needs to make sure all decoration lights in the office is turned off. The decoration lights are unique: each of them has a timer that will switch the light on or off every two seconds. The lights are also arranged so well that each two neighboring lights will have different state (on/off). As long as the timer...

  • C Programming Language The code below matches the sample input/output but is marked wrong. Are there...

    C Programming Language The code below matches the sample input/output but is marked wrong. Are there other ways to do this problem? The focus is on recursion and functions. #include<stdio.h> int joCheck(unsigned long long int number) { if(number % 7 == 0 || number % 8 == 0) { return 1; } else return 0; } int main() { int cases = 0; scanf("%d", &cases); for(int i = 1; i<=cases; i++) { unsigned long long int number; scanf("%d", &number); if(joCheck(number)...

  • C Programming Language Problem Title: Komodo National Park Do You know that Komodo National Park, located...

    C Programming Language Problem Title: Komodo National Park Do You know that Komodo National Park, located in Nusa Tenggara Timur (NTT), is a World Heritage Site by UNESCO, the specialized agency under United Nations (UN). One day, Lili and Bibi were on vacation on one of the islands in the Komodo National Park area and they just realized that they were living alone on that island because the cot- tage owner was completing his unfinished business on the main island....

  • I need help writing these functions in C programming. Write a C function that checks if...

    I need help writing these functions in C programming. Write a C function that checks if an array is sorted or not using an iterative approach. Write a C function that checks if an array is sorted or not using a recursive approach Write a C function to reverse the elements of an array. Note you are not allowed to use an 1. additional array to do that Write a C function to find the sum of the elements of...

  • Use c++ as programming language. The file needs to be created ourselves (ARRAYS) Write a program...

    Use c++ as programming language. The file needs to be created ourselves (ARRAYS) Write a program that contains the following functions: 1. A function to read integer values into a one-dimensional array of size N. 2. A function to sort a one-dimensional array of size N of integers in descending order. 3. A function to find and output the average of the values in a one dimensional array of size N of integers. 4. A function to output a one-dimensional...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT