Click here to Skip to main content
14,734,709 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Because Jake got an early offer from UOIT, his overjoyed parents gave him a lot of Rubik's Cubes as a reward. However, he soon developed Carpal Tunnel Syndrome, and now has to sell some of his cubes at half of their original price to pay for his medical bills.
Jake is a very unique person; the N cubes that he got each have a distinct value Vi, and are placed in a straight line. He wants to know if he has a total of at least M dollars after he sells all of his cubes inclusively between the one valued at Va and the one valued at Vb (in the line). He specifically wants to ask Q questions in the form (Va,Vb) to know if he has enough money after selling all of the cubes in that range. Both cubes are guaranteed to exist in the sequence.
Note: it may be helpful to use unsigned 64-bit variables (e.g. unsigned long long in C++).

Constraints
Subtask 1 [10%]
• 1≤N, Q≤100
• 1≤M, V≤1000

Subtask 2 [90%]
• 1≤N,Q≤100000
• 1≤M≤10000000
• 1≤V≤1000000

Input Specification
The first line of input will consist of 3 space-separated integers N, M, and Q. The next line will contain N space-separated integers, where the ith integer represents the Vith value. For the next Q lines, each line will contain 2 space separated integers Va and Vb.

Output Specification
For each question, output Enough if jake can afford his bills or Not enough if he cannot.

Sample Input

5 10 2
10 1 4 3 7
1 3
10 7

Sample Output

Not enough
Enough

What I have tried:

I'm not specefically looking for a code but wondering if someone can explain what the question is exactly asking. I just started coding about 48 hours ago, and realized I do not really understand the format of questions present on some website.

From what I can understand I have several cubes in a line, each with a respective value of V. Each cube (or vi, vi+1, vi+2... vi+n) has a money value. In subsets of VA to VB which can be as large as 100 (q<= 100) i add them sequentially. The subest procudes a value of (lets say) R. I then check the value of R to be either greater than M or less than M. If it is less than R, than I loop back to the begining and try with a different subset. If the value of R is equal to or greater than M, then i set the counter to 1 and repeatthe entire loop until the value of the counter is equal to Q. This is what I understand but not sure if this is what it is asking, can some one help to clarify?
Posted
Updated 19-Feb-17 23:00pm
v4
Comments
[no name] 19-Feb-17 18:23pm
   
Okay done.
MadMuffinzOG 19-Feb-17 21:07pm
   
actually at this point just wanna send me the code lol XD

To me the question is clear: each query line gives you the starting value Va and the end value Vb. You have to find both Va and Vb in the sequence of values and then sum all the values between Va and Vb included. If such sum is bigger than, or equal to, M then print 'enough' if, on the other end, the sum is less than M then print 'not enough'.
   
v2
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.

[Update]
Quote:
I'm not specefically looking for a code but wondering if someone can explain what the question is exactly asking. I just started coding about 48 hours ago, and realized I do not really understand the format of questions present on some website.

You are a beginner. so stop trying to solve random problems on internet, some of them are meant for skilled programmers, other are challenges for advanced programmers.
Advice: Find tutorial sites follow them, do the exercises, their difficulty is progressive and match the level of tutos.
   
v2
Nope, nope, nope. We are not here to do your homework for you.

Why? Because the next assignment will build on this one. If we do it for you you learn absolutely nothing, putting yourself even farther behind and eventually failing the class.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900